日期:2014-05-17  浏览次数:20879 次

如何得到 未提交的文本域的值
<html   xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 "   />
<title> 无标题文档 </title>
</head>

<body>
<form   id= "form1 "   name= "form1 "   method= "post "   action= "asdf.asp ">
    <label> 性别   男
    <input   type= "radio "   name= "radiobutton "   value= "男 ">
    女
    <input   type= "radio "   name= "radiobutton "   value= "女 ">
    </label>
    <label>
    <input   type= "submit "   name= "Submit "   value= "提交 ">
    </label>
</form>
<label> </label>
</body>
</html>
如何在未提交的情况下获得单选按钮的值     即value值

------解决方案--------------------

<input type= "radio " name= "radiobutton " value= "男 " onclick= "alert(this.value) ">

<input type= "radio " name= "radiobutton " value= "女 " onclick= "alert(this.value) ">
------解决方案--------------------
form1.radiobutton[0].value
form1.radiobutton[1].value
分別為兩個單選按鈕的值
------解决方案--------------------
document.form1.getElementsByName( "radiobutton ")[0].value
document.form1.getElementsByName( "radiobutton ")[1].value