请教js的一个小问题。
html代码
HTML code <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>
问题是我这样获取不到所需要的值,js部分应该怎么写?
------解决方案--------------------
alert(obj.acontent.value);
你应该这么写 才能获取到值
------解决方案--------------------
查询谷 - www.chaxungu.com
请问js的一个小疑点
编辑:chaxungu时间:2022-10-02 23:16:00分类:web开发