怎样将里面的input的值读出来,或者给input赋值
- HTML code
<TABLE style="WIDTH: 920px; BORDER-COLLAPSE: collapse; WORD-WRAP: break-word; TABLE-LAYOUT: auto; HEIGHT: 52px" id=detail border=1 borderColor=buttontext><TBODY><TR><TD style="MIN-WIDTH: 15px; WORD-BREAK: break-all"><P align=center> A</P></TD><TD style="MIN-WIDTH: 15px; WORD-BREAK: break-all"><P align=center> B</P></TD><TD style="MIN-WIDTH: 15px; WORD-BREAK: break-all"><P align=center> C</P></TD><TD style="MIN-WIDTH: 15px; WORD-BREAK: break-all"><P align=center> D</P></TD><TD style="MIN-WIDTH: 15px; WORD-BREAK: break-all"><P align=center> E</P></TD></TR><TR><TD style="MIN-WIDTH: 15px; WORD-BREAK: break-all"><P align=center><SELECT style="WIDTH: 111px; FONT-FAMILY: ËÎÌå" id=field4 onchange=showDeps(this) mathrulescript tableType="1" level="2" enumId="-3"><OPTION selected value=10001>¼¼Êõ²¿</OPTION><OPTION value="">--ÇëÑ¡Ôñ²¿ÃÅ--</OPTION></SELECT></P></TD><TD style="MIN-WIDTH: 15px; WORD-BREAK: break-all"><P align=center><INPUT style="FONT-FAMILY: ËÎÌå" id=field5 maxLength=50 mathrulescript tableType="1" level="2" enumId="0"></P></TD><TD style="MIN-WIDTH: 15px; WORD-BREAK: break-all"><P align=center><INPUT style="FONT-FAMILY: ËÎÌå" id=field6 maxLength=50 mathrulescript tableType="1" level="2" enumId="0"></P></TD><TD style="MIN-WIDTH: 15px; WORD-BREAK: break-all"><P align=center><INPUT style="FONT-FAMILY: ËÎÌå" id=field7 maxLength=50 mathrulescript tableType="1" level="2" enumId="0"></P></TD><TD style="MIN-WIDTH: 15px; WORD-BREAK: break-all"><P align=center><INPUT style="FONT-FAMILY: ËÎÌå" id=field8 ondrop="return false" onkeyup="checkNumber(this,'10','2')" maxLength=50 mathrulescript tableType="1" level="2" enumId="0"><INPUT style="DISPLAY: none; FONT-FAMILY: ËÎÌå" id=field9 onkeyup="checkNumber(this,'10','2')" readOnly maxLength=50 mathrulescript tableType="1" level="1" enumId="0"><FONT style="FONT-FAMILY: ËÎÌå; COLOR: #000099; FONT-SIZE: 14px" id=field9_level_font></FONT></P></TD></TR><TR><TD style="MIN-WIDTH: 15px; WORD-BREAK: break-all" background=""><P align=center><SELECT style="WIDTH: 111px; FONT-FAMILY: ËÎÌå" id=field4 onchange=showDeps(this) mathrulescript tableType="1" level="2" enumId="-3"><OPTION selected value=10001>¼¼Êõ²¿</OPTION><OPTION value="">--ÇëÑ¡Ôñ²¿ÃÅ--</OPTION></SELECT></P></TD><TD style="MIN-WIDTH: 15px; WORD-BREAK: break-all" background=""><P align=center><INPUT style="FONT-FAMILY: ËÎÌå" id=field5 maxLength=50 mathrulescript tableType="1" level="2" enumId="0"></P></TD><TD style="MIN-WIDTH: 15px; WORD-BREAK: break-all" background=""><P align=center><INPUT style="FONT-FAMILY: ËÎÌå" id=field6 maxLength=50 mathrulescript tableType="1" level="2" enumId="0"></P></TD><TD style="MIN-WIDTH: 15px; WORD-BREAK: break-all" background=""><P align=center><INPUT style="FONT-FAMILY: ËÎÌå" id=field7 maxLength=50 mathrulescript tableType="1" level="2" enumId="0"></P></TD><TD style="MIN-WIDTH: 15px; WORD-BREAK: break-all" background=""><P align=center><INPUT style="FONT-FAMILY: ËÎÌå" id=field8 ondrop="return false" onkeyup="checkNumber(this,'10','2')" maxLength=50 mathrulescript tableType="1" level="2" enumId="0"><INPUT style="DISPLAY: none; FONT-FAMILY: ËÎÌå" id=field9 onkeyup="checkNumber(this,'10','2')" readOnly maxLength=50 mathrulescript tableType="1" level="1" enumId="0"><FONT style="FONT-FAMILY: ËÎÌå; COLOR: #000099; FONT-SIZE: 14px" id=field9_level_font></FONT></P></TD></TR><TR><TD style="MIN-WIDTH: 15px; WORD-BREAK: break-all" background=""><P align=center><SELECT style="WIDTH: 111px; FONT-FAMILY: ËÎÌå" id=field4 onchange=showDeps(this) mathrulescript tableType="1" level="2" enumId="-3"><OPTION selected value=10001>¼¼Êõ²¿</OPTION><OPTION value="">--ÇëÑ¡Ôñ²¿ÃÅ--</OPTION></SELECT></P></TD><TD style="MIN-WIDTH: 15px; WORD-BREAK: break-all" background=""><P align=center><INPUT style="FONT-FAMILY: ËÎÌå" id=field5 maxLength=50 mathrulescript tableType="1" level="2" enumId="0"></P></TD><TD style="MIN-WIDTH: 15px; WORD-BREAK: break-all" background=""><P align=center><INPUT style="FONT-FAMILY: ËÎÌå" id=field6 maxLength=50 mathrulescript tableType="1" level="2" enumId="0"></P></TD><TD style="MIN-WIDTH: 15px; WORD-BREAK: break-all" background=""><P align=center><INPUT style="FONT-FAMILY: ËÎÌå" id=field7 maxLength=50 mathrulescript tableType="1" level="2" enumId="0"></P></TD><TD style="MIN-WIDTH: 15px; WORD-BREAK: break-all" background=""><P align=center><INPUT style="FONT-FAMILY: ËÎÌå" id=field8 ondrop="return false" onkeyup="checkNumber(this,'10','2')" maxLength=50 mathrulescript tableType="1" level="2" enumId="0"><INPUT style="DISPLAY: none; FONT-FAMILY: ËÎÌå" id=field9 onkeyup="checkNumber(this,'10','2')" readOnly maxLength=50 mathrulescript tableType="1" level="1" enumId="0"><FONT style="FONT-FAMILY: ËÎÌå; COLOR: #000099; FONT-SIZE: 14px" id=field9_level_font></FONT></P></TD></TR></TBODY></TABLE>
怎样将里面的input的值读出来,或者给input赋值
[解决办法]
getElementsByTagName然后遍历
- HTML code
<script type="text/javascript"> function Read() { var ips = document.getElementById('detail').getElementsByTagName('input'); for (var i = 0, j = ips.length; i < j; i++) alert('第'+(i+1)+'个输入框的值:' + ips[i].value); } function Set() { var ips = document.getElementById('detail').getElementsByTagName('input'); for (var i = 0, j = ips.length; i < j; i++) ips[i].value = i + 1; }</script><input type="button" value="读数据" onclick="Read()"/>|<input type="button" value="设置数据" onclick="Set()"/>
[解决办法]
document.getElementById("field6").value ;
document.getElementById("field6").value ="新值";
[解决办法]
楼上已有答案了。建议你把javaScript基础的东西好好看看。