Use the jquery selector in the input set or loop

Source: Internet
Author: User

<Script language = "JavaScript" src = "jquery-1.6.2.min.js"> </SCRIPT>
<Body>
<Form>

<Table>
<Thead>
<Tr>
<TD width = "100px" align = "center"> </TD>
<TD width = "100px" align = "center"> column 1 </TD>
<TD width = "100px" align = "center"> Column 2 </TD>
<TD width = "100px" align = "center"> column 3 </TD>
</Tr>
</Thead>
<Tbody id = "tablebody">
</Tbody>
<Font color = 'red'> select a row and click Submit </font>
<Input id = "BTN" type = "Submit" value = "Submit" onclick = "CC ();"/>
</Table>

<HR> <br>

<Table>
<Thead>
<Tr>
<TD width = "150px"> column 1 </TD>
<TD width = "150px"> Column 2 </TD>
<TD width = "150px"> column 3 </TD>
<TD width = "150px"> column 4 </TD>
</Tr>
</Thead>
<Tbody id = "tablebody2">
<Tr>
<TD> contains multiple hidden Domains
<Input type = "hidden" value = "1 line inputvalue1"/>
<Input type = "hidden" value = "1 line inputvalue2"/>
<Input type = "hidden" value = "1 line inputvalue3">
<Input type = "hidden" value = "1 line inputvalue4">
<Input type = "hidden" value = "1 line inputvalue5">
<Input name = "inputvalue6" type = "hidden" value = "1 line inputvalue6">
</TD>
<TD> innerhtml in one row and two columns </TD>
<TD> innerhtml in one row and three columns </TD>
<TD> <a style = "cursor: hand;" onclick = "openpanel (this);"> modify </a> </TD>
</Tr>
<Tr>
<TD> contains multiple hidden Domains
<Input type = "hidden" value = "2 rows of inputvalue1"/>
<Input type = "hidden" value = "2 rows inputvalue2"/>
<Input type = "hidden" value = "2 rows of inputvalue3">
<Input type = "hidden" value = "2 rows of inputvalue4">
<Input type = "hidden" value = "2 rows inputvalue5">
<Input name = "inputvalue6" type = "hidden" value = "2 rows of inputvalue6">
</TD>
<TD> 2 rows and 2 columns of innerhtml </TD>
<TD> 2 rows and 3 columns of innerhtml </TD>
<TD> <a style = "cursor: hand;" onclick = "openpanel (this);"> modify </a> </TD>
<Font color = 'red'> click to modify </font>
</Tr>
</Tbody>
</Table>

</Form>
</Body>
<SCRIPT type = "text/JavaScript">
$ (Document). Ready (function (){
VaR trtd = "<tr align = 'center'> <TD> <input type = 'checkbox' readonly style = 'width: 20px; '> </TD>"
+ "<TD> <input name = 'strzzfw1' type = 'text' value = 'style = 'width: 40px '> </TD>"
+ "<TD> <input name = 'strzzfw2 'type = 'text' value = 'style = 'width: 40px'> </TD>"
+ "<TD> <input name = 'strzzfw3' type = 'text' value = '1 rows and 3 columns 'style = 'width: 40px'> </tr>"
+ "<Tr align = 'center'> <TD> <input type = 'checkbox' readonly style = 'width: 20px; '> </TD>"
+ "<TD> <input name = 'strzzfw1 'type = 'text' value = '2 rows and 1 column value' style = 'width: 40px '> </TD>"
+ "<TD> <input name = 'strzzfw2 'type = 'text' value = '2 rows and 2 columns' style = 'width: 40px '> </TD>"
+ "<TD> <input name = 'strzzfw3' type = 'text' value = '2 rows and 3 columns 'style = 'width: 40px '> </tr> ";
$ ("# Tablebody"). append (trtd );
});
Function CC (){
VaR $ chkarry = $ ('input [type = "checkbox"] '). Not ($ (' # checkedall '));
$ Chkarry. Each (function (INDEX ){
If ($ chkarry. eq (INDEX). ATTR ('checked ')){
VaR $ item = $ chkarry. eq (INDEX). Parent (). Parent ();
VaR $ ins = $ item. Find ("input ");
Alert ($ ("input [type = 'text'] [name = 'strzzfw3']", $ item). Val ());
Alert ($ ins. eq (3). Val ());
}
});
}

Function openpanel (OBJ ){
VaR $ TR = $ (OBJ). Parent (). Parent ();
VaR $ ins = $ tr. Children (). eq (1). Find ("input ");
Alert ($ ("input [type = 'den den '] [name = 'inputvalue6']", $ TR). Val ());
Alert ($ tr. Children (). eq (0). Children (). eq (5). Val ());
Alert(fig ());
Alert(fig ());
Alert(fig ());
}
</SCRIPT>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.