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 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 UE5#if WITH_EDITOR导致打包的功能不可用
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面
  • ¥15 算法题:数的划分,用记忆化DFS做WA求调