duanlanqian9974 2014-08-22 14:21
浏览 40

使用jquery填充下拉列表:未在​​表单中发布值

I had to change the values of a dropdown basis the selection of a radio button so i used jquery to check the selected radio button and populated the dropdown accordingly.

Now, when i select a value from the dropdown and submit the form the dropdown value doesnt get posted. Please help. The code i used :

<select style="width:120px;  margin-left:5px;" name="sPriceMin1" id="describe1">
<option value="" selected>Min Price</option> 

in the script :

var listA = [{name:'0', value:'0'}, {name:'10 Lacs', value:'1000000'}, {name:'20 Lacs', value:'2000000'},{name:'30 Lacs', value:'3000000'},{name:'50 Lacs', value:'5000000'},{name:'70 Lacs', value:'7000000'},{name:'1 Cr', value:'10000000'},{name:'1.5 Cr', value:'15000000'},{name:'2 Cr', value:'20000000'},{name:'3 Cr', value:'30000000'},{name:'5 Cr', value:'50000000'}];

$(document).ready( function() {
$('#describe1').empty();                              
      $.each(listA, function(index, value) {
        $('#describe1').append('<option value="'+value.value+'">'+value.name+'</option>');
        });
});

I am unable to fetch the values of the dropdown in my php code. Please help.

  • 写回答

1条回答 默认 最新

  • drvxclagw656708070 2014-08-22 14:27
    关注

    Try creating the select option's this way:

    $(document).ready( function() {
        var dd = $('#describe1');
        dd.empty();                              
        $.each(listA, function() {
            $("<option />", {
                val: this.value,
                text: this.name
            }).appendTo(dd);
        });
    });
    

    Also, make sure that your select is inside the form tag.

    Since you did not post the PHP code, it is difficult to tell if this advice will help you.

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作