请教一个关于调用函数的问题!
function setSubjectText(){
if(trim(document.form.radiobutton.value) == " ") {
alert( "请选择交易类型 ");
return false;
}
}
<form method= "POST " action= "save_product.asp " name= "form " >
<input type= "radio " name= "radiobutton " value= " ">
<INPUT class=subbutton style= "WIDTH: 160px " onclick=javascript:setSubjectText() type=button value=一切完成,我要发布! name=Post>
</form>
为什么弹不出 "请选择交易类型 "这个对话框呢?请帮忙分析一下.
------解决方案-------------------- <script language= "javascript ">
function setSubjectText(){
var str;
str = false;
for(i=0;i <form.radiobutton.length;i++)
{
if(form.radiobutton[i].checked==true)
{
str = true;
break;
}
}
if(!str)
{
alert( "请选择交易类型 ");
return false;
}
}
</script>
<form method= "POST " action= "save_product.asp " name= "form " >
<input type= "radio " name= "radiobutton " value= " ">
<input type= "radio " name= "radiobutton " value= " ">
<input type= "radio " name= "radiobutton " value= " ">
<INPUT class=subbutton style= "WIDTH: 160px " onclick=javascript:setSubjectText() type=button value=一切完成,我要发布! name=Post>
</form>