JS Dynamic Loading Control JSP page

Source: Internet
Author: User

Example 1(For details, refer to flow_card_add.jsp in DRP)
<SCRIPT>
VaR rowindex = 0;
Function addonelineonclick (){
VaR ROW = tblflowcarddetail. insertrow (tblflowcarddetail. Rows. Length );
VaR Col = row. insertcell (0 );
Col. innerhtml = "<input type = \" Hidden \ "name = \" aiminnerid \ "id = \" aiminnerid \ "> <input type = button value =... name = btnselectaimclient Index = \ "" + rowindex + "\"> ";
Col = row. insertcell (1 );
Col. innerhtml = "<input id = aimname name = aimname size = 25 maxlength = 25 readonly = \" True \ "> ";
Col = row. insertcell (2 );
Col. innerhtml = "<input type = 'button 'value = 'delete' id = btndeleteline name = btndeleteline onclick = \" Return deleterow ('row "+ rowindex + "') \ "> ";
Row. setattribute ("ID", "row" + rowindex );
Rowindex ++;
}
Function deleterow (rowtag ){
VaR I = tblflowcarddetail. Rows (rowtag). rowindex;
VaR J;
For (j = I; j <= rowindex; j ++ ){
Tblflowcarddetail. Rows (j). cells (0). All ("btnselectaimclient"). Index --;
Tblflowcarddetail. Rows (j). cells (2). All ("btnselectitem"). Index --;
}
Tblflowcarddetail. deleterow (I );
Rowindex --;
}
</SCRIPT>

<Body>
<Table>
<Tr>
<TD> cell0 </TD>
<TD> cell1 </TD>
<TD> cell2 </TD>
</Tr>
</Table>
<Input name = "btnaddline" type = "button" id = "btnaddline" onclick = "Return addonelineonclick ()" value = "add a row">
</Body>

Example 2:
<Body>
<Form action = "<% = PATH %>/news. do? Method = Add "method =" Post "enctype =" multipart/form-Data ">
<Input type = "hidden" name = "ID" value = "$ {NEWS. ID}">
<Table width = "90%" border = "0" align = "Left" cellpadding = "0" cellspacing = "1" class = "newtable">
<Tr>
<TD class = "newtd"> News Title </TD>
<TD class = "newtd"> <input type = "text" name = "title" size = "30"> </TD>
</Tr>
<Tr>
<TD class = "newtd"> News subtitle </TD>
<TD class = "newtd"> <input type = "text" name = "subtitle" size = "30"> </TD>
</Tr>
<Tr>
<TD class = "newtd"> news content </TD>
<TD class = "newtd"> <textarea class = "ckeditor" name = "content"> </textarea> </TD>
</Tr>
<Tr>
<TD class = "newtd"> news images </TD>
<TD class = "newtd" id = "more"> <input type = "file" name = "uploadfile [0]. file "size =" 30 "> <input type =" button "onclick =" AddFile (); "value =" add "> </TD>
</Tr>
<Tr>
<TD class = "newtd"> News section </TD>
<TD class = "newtd">
<Select id = "modelselect" name = "modelid">
</SELECT>
</TD>
</Tr>
<Tr>
<TD align = "center" colspan = "2">
<Input type = "Submit" value = "save"> & nbsp;
<Input type = "reset" value = "reset">
</TD>
</Tr>
</Table>
</Form>

<SCRIPT type = "text/JavaScript">
VaR T = 1;
Function AddFile ()
{
VaR parent = Document. getelementbyid ("more ");
VaR BR = Document. createelement ("Br ");
VaR input = Document. createelement ("input ");
VaR button = Document. createelement ("input ");
Input. type = "file ";
Input. Name = "uploadfile [" + (T ++) + "]. File ";
Input. size = "30 ";
Button. type = "button ";
Button. value = "delete ";
Button. onclick = function ()
{
Parent. removechild (BR );
Parent. removechild (input );
Parent. removechild (button );

};
Parent. appendchild (BR );
Parent. appendchild (input );
Parent. appendchild (button );
}
</SCRIPT>
</Body>

Related Article

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.