<SCRIPT language=javascript>
<!--
function checkpkg(n){
if("form" + n +."price.value" == "")
{
alert("!!!!!!!!!!!!") ;
return false;
}
return true;
}
//-->
</SCRIPT>
<form action="pkg2.asp" method="post" name="form330" onSubmit="return checkpkg('330');">
<input name="price" type="hidden" id="price" />
</form>上边的js哪里有错,请高手指正?
<!--
function checkpkg(n){
if("form" + n +."price.value" == "")
{
alert("!!!!!!!!!!!!") ;
return false;
}
return true;
}
//-->
</SCRIPT>
<form action="pkg2.asp" method="post" name="form330" onSubmit="return checkpkg('330');">
<input name="price" type="hidden" id="price" />
</form>上边的js哪里有错,请高手指正?
document.forms["form"+n].price.value
<!--
//function checkpkg(n){
//if("form" + n +."price.value" == "")
//{
//alert("!!!!!!!!!!!!") ;
//return false;
//}
//return true;
//}
function showvalue(n)
{
//alert(form1.price.value);
var str="form" + n +".price.value";
var v=eval("("+ str +")");
alert(v);
}
//-->
</SCRIPT>
<form name="form1">
<input name="price" id="price" value="101" />
<input type="button" onclick="showvalue(1);" value="test" />
</form>
<SCRIPT language=javascript>
<!--
function checkpkg(n){
if(eval("form" + n +".price.value") == "")
{
alert("!!!!!!!!!!!!") ;
return false;
}return true;
}//-->
</SCRIPT>
<form action="pkg2.asp" method="post" name="form330" onSubmit="return checkpkg('330');">
<input name="price" type="hidden" id="price" value="12"/>
</form>
你的逗号写在引号外面啦