您的位置:首页 > Web前端 > HTML

html多种方法读取表单的元素值

2008-10-30 11:02 417 查看
<html>
<script language="javascript">
function ylgetvalue(obj)
{
//方法1
var objj=eval(obj.wo_sign);
alert('eval(obj.wo_sign):'+objj.value);

//方法2
objj=obj.wo_sign;
alert('obj.wo_sign:'+objj.value);

//方法3
objj=eval('document.forms[0].wo_sign');
alert('document.forms[0].wo_sign:'+objj.value);

//方法4
objj=eval('document.all.wo_sign');
alert('document.all.wo_sign:'+objj.value);

//方法5
objj=document.all.wo_sign;
alert('document.all.wo_sign:'+objj.value);

//方法6
objj=document.all['wo_sign'];
alert('document.all["wo_sign"]:'+objj.value);

//方法7
objj=document.getElementsByName('wo_sign')[0];
alert('document.getElementsByName("wo_sign"):'+objj.value);
}
</script>
<title>html多种方法读取表单的元素值 by yl yanleigis</title>
<form name="yanleigisform" method="post">

<tr>

</tr>

</table>
<table width="200" border="1">
<tr>
<td>by yl yanleigis,email:landgis@126.com </td>
<td> <input type="hidden" name="wo_sign" value="by yl yanleigis,email:landgis@126.com "></td>
</tr>
<tr>
<td><input type="button" name="yl" value="获得值" onClick="ylgetvalue(yanleigisform)"></td>
<td>2008.10.29 by yl</td>
</tr>
</table>
</form>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: