doutiao2540 2011-06-15 09:32
浏览 31
已采纳

AJAX RADIO BUTTON不工作

I have 3 radio buttons.

<input type="radio" name="length" value="1">
<input type="radio" name="length" value="2">
<input type="radio" name="length" value="3">

and im passing this values using like this. name,bay,pall,dest working fine. but length output as "undefined". please help me to fine this error.. thanks..

this is my ajax codE:

    $(document).ready(function()

{



    $("#bcode").focus();
    //prevents autocomplete in some browsers
    $("#bcode").attr('autocomplete', 'off').keyup(function(event)
    {

                var name = $("#bcode").val();
                var bay  = $("#select").val();
                var pall = $("#select2").val();
                var dest = $("#select4").val();
                var length = $("#length").val();


            $("#status").empty();
            if(name.length > 17 )
            {
                selectAll();

                $("#status").html('<img align="absmiddle" src="images/loading.gif" /> Checking availability...').show();




     $.ajax({
                    type: "POST",
                    url: "namecheck.php",
                    data : "bcode=" + name + "&select=" + bay+ "&select2=" + pall+ "&select4=" + dest+ "&length=" + length,
                    success: function(msg)
                    {
                        $("#status").html(msg).show();
                    }
                    });

        }
        else
        {
            $("#status").html('').addClass('err').show();
        }
    });
    });
  • 写回答

1条回答 默认 最新

  • dsu5188 2011-06-15 09:40
    关注

    I think this is wrong: var length = $("#length").val(); it should be

    var length = $("input[name=length]:checked").val();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 github符合条件20分钟秒到账,github空投 提供github账号可兑换💰感兴趣的可以找我交流一下
  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?