JS遍历控件取值,去某行的所有控件的值
2009-09-11 10:27
204 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>JS遍历控件取值</title> <mce:script type="text/javascript"><!-- function Submit() { var Text=document.getElementsByTagName("input"); var Array=""; for(var i=0;i<Text.length;i++) { if(Text[i].type=="text"||Text[i].type=="checkbox") { Array+=","; Array+=Text[i].value; } } Array=Array.substring(1,Array.length); alert(Array); } // --></mce:script> </head> <body> <table> <tr> <td style="width: 100px"> <input id="Checkbox1" type="checkbox" value="胡果" />胡果</td> <td style="width: 100px"> <input id="Text1" type="text" value="ws_hgo" /></td> <td style="width: 100px"> <input id="Button1" type="button" value="button" onclick="Submit(this)" /></td> </tr> </table> </body> </html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>JS某行的所有控件的值</title> <mce:script type="text/javascript"><!-- function Submit(obj) { var str=""; var tr=obj.parentNode.parentNode; var chk=tr.childNodes[0].childNodes[0]; if(chk.checked) { str=chk.value; } var txt=tr.childNodes[1].childNodes[0]; str+=txt.value; alert(str); } // --></mce:script> </head> <body> <table> <tr> <td style="width: 100px"> <input id="Checkbox1" type="checkbox" value="胡果" />胡果</td> <td style="width: 100px"> <input id="Text1" type="text" value="ws_hgo" /></td> <td style="width: 100px"> <input id="Button1" type="button" value="button" onclick="Submit(this)" /></td> </tr> <tr> <td style="width: 100px"> <input id="Checkbox2" type="checkbox" value="果果" />果果</td> <td style="width: 100px"> <input id="Text2" type="text" value="hgo" /></td> <td style="width: 100px"> <input id="Button2" type="button" value="button" onclick="Submit(this)" /></td> </tr> </table> </body> </html>
相关文章推荐
- JS遍历所有所有控件
- JS遍历控件取值
- js遍历页面所有控件(部分控件)
- winform 遍历窗体中所有用户控件中的textbox 然后赋为空值
- 遍历窗口中所有控件及ContextMenuStrip、Timer控件
- 遍历js的obj中所有属性得key
- Js 怎么遍历json对象所有key及根据动态key获取值
- Js 怎么遍历json对象所有key及根据动态key获取值
- 关于类的入门例子(8): 遍历窗体中所有控件的函数
- 遍历所有控件
- 遍历JavaScript对象的所有属性(js反射机制)
- 原生js遍历自定义json所有数据
- 如何在ASP.NET下遍历指定页面上所有控件[原创]
- 循环遍历获取窗体或页面所有同类型的控件
- 遍历窗体中的所有TextBox控件,并为其赋值
- 遍历控件中的所有控件 并设置显示属性
- asp.net(C#)遍历页面上所有的TextBox控件并给它赋值
- 如何在ASP.NET下遍历指定页面上所有控件
- 遍历form中所有的控件
- C#遍历窗体所有控件或某类型所有控件