AJAX 单选按钮不工作
我有 3 个单选按钮。
<input type="radio" name="length" value="1">
<input type="radio" name="length" value="2">
<input type="radio" name="length" value="3">
我使用这样的方式传递这个值。 name,bay,pall,dest 工作正常。但长度输出为“未定义”。请帮我解决这个错误..谢谢..
这是我的ajax代码:
$(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();
}
});
});
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();
}
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这是错误的: var length = $("#length").val(); 应该是
I think this is wrong:
var length = $("#length").val();
it should be