日期:2014-05-16 浏览次数:20561 次
<script type="text/javascript">
function CheckInput(obj,type){
var content = type+'content';
alert(content);
alert(obj.content.value);
//问题出在这里,怎么获取不到表单的值呢?
return false;
}
</script>
<form action="save.php" method="post" name="aform" onsubmit="return CheckInput(this,'a')">
<input type="text" name="acontent" />
<input type="submit" name="submit" value="发布" />
</form>
<form action="save.php" method="post" name="bform_1" onsubmit="return CheckInput(this,'b')">
<input type="text" name="bcontent" />
<input type="submit" name="submit" value="发布" />
</form>
<form action="save.php" method="post" name="bform_2" onsubmit="return CheckInput(this,'b')">
<input type="text" name="bcontent" />
<input type="submit" name="submit" value="发布" />
</form>
<script type="text/javascript">
function CheckInput(obj,type){
var content = type+'content';
alert(obj.content.value); //对象没有这么组合的。应该改为:obj.elements[content].value;
return false;
}
</script>