duanpacan2583 2015-05-29 05:56
浏览 574
已采纳

单选按钮值未存储在数据库中

I created a radio button in which when user click on yes value then text box is shown to user otherwise they remain hide.
My question when user select yes then I am able to store yes value in sql but when user click on no value that value is not stored in datbase

<script>
$(document).ready(function(){
  $(function() {
     $('input[name="yeshave"]').on('click', function() {
        if ($(this).val() == 'yes') {
           $('#textboxes').show();
        } else {
           $('#textboxes').hide();
        }
     });
   });
});
</script>

no radio button code:

<table>
   <tr>
      <td>Do you haver passport:</td>
      <td><input type="radio" name="yeshave" value="yes"> Yes</td>
      <td><input type="radio" name="yeshave" value="no"> No</td>
   </tr>
</table>

SQL code is:

if(isset($_POST['yeshave']))
{
    $selectedValue=$_POST['yeshave'];
}



 $query = "INSERT INTO upload (name, size, type, image,passport_no,dateofissue,dateofexpiry,placeofissue, having_passport ) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$image','".$passno."','".$doi."','".$doe."','".$poi."','".$selectedValue."')";

mysqli_query($conn,$query) or die('Error, query failed');
  • 写回答

2条回答 默认 最新

  • douxunwei8259 2015-05-29 06:00
    关注

    Set check one of them. Try with -

    $selectedValue = isset($_POST['yeshave']) ? $_POST['yeshave'] : 'no';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?