<% & #64; Page Language = "Java" Import = "Java. util. *, Com. Page. Wash. giveclothing. *" pageencoding = "GBK" %>
<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en">
<HTML>
<Head>
<Title> Add Table Information </title>
<Meta http-equiv = "Pragma" content = "no-Cache"/>
<Meta http-equiv = "cache-control" content = "no-Cache"/>
<Meta http-equiv = "expires" content = "0"/>
<Meta http-equiv = "keywords" content = "keyword1, keyword2, keyword3"/>
<Meta http-equiv = "Description" content = "this is my page"/>
<SCRIPT type = "text/JavaScript">
Function addrow ()
{
// Add a row
VaR I = tab1.rows. length;
VaR Nam = "'div1 '";
VaR cod = "Fuj" + I;
VaR newtr = tab1.insertrow ();
// Add a column
VaR newtd0 = newtr. insertcell ();
VaR newtd1 = newtr. insertcell ();
VaR newtd2 = newtr. insertcell ();
VaR newtd3 = newtr. insertcell ();
// Set the column content and attributes
Newtd0.innerhtml = '<input type = "checkbox" id = "box1" onclick = "getrow () "//> <input type =" hidden "name =" Fuj "id = '+ cod +'/> ';
Newtd1.innerhtml = "Clothes size ";
Newtd2.innerhtml = "Clothes ";
Newtd3.innerhtml = "processing type ";
}
Function delrow ()
{
// Delete a row
VaR Shu = 0;
VaR checou = Document. All ("box1 ");
For (VAR I = 0; I <checou. length; I ++)
{
If (checou [I]. Checked = true)
{
Shu ++;
}
}
If (Shu = checou. length)
{
Alert ('add at least one body ');
Return;
}
Else if (Shu = 0)
{
Alert ('select the information you want to delete ');
Return;
}
Else if (Shu = 1)
{
For (VAR I = 0; I <checou. length; I ++)
{
If (checou [I]. Checked = true)
{
Tab1.deleterow (I + 1 );
}
}
}
Else if (Shu> 1)
{
For (VAR a = 0; A <shu; A ++)
{
For (VAR I = 0; I <checou. length; I ++)
{
If (checou [I]. Checked = true)
{
Tab1.deleterow (I + 1 );
Break;
}
}
}
}
}
Function getrow ()
{
// Obtain the row Index
// The two parentelements are TD and TR respectively, and rowindex is the attribute of TR.
// This. parentelement. parentelement. rowindex
Cgetrow = Window. event. srcelement. parentelement. parentelement. rowindex;
}
</SCRIPT>
</Head>
<Body>
<Form name = "form1" Action = "$ {pagecontext. Request. contextpath}/giveclothing. do? Method = fujiafei "method =" Post ">
<Center>
<Fieldset>
<Legend> <strong> dynamically Add a table </strong> </legend>
<Input type = hidden id = "hid" name = "hid" //>
<Table id = "tab1" align = "center" border = "1" cellpadding = "4" cellspacing = "0" bordercolorlight = "#999999" bordercolordark = "# ffffff" Style = "width: 95%; Word-break: Break-all ">
<Thead>
<Tr>
<TH align = "center" width = "10%"> select </Th>
<TH align = "center" width = "15%"> Clothes size </Th>
<TH align = "center" width = "15%"> Clothes </Th>
<TH align = "center" width = "15%"> processing type </Th>
</Tr>
</Thead>
<Tr>
<TD> <input type = checkbox id = "box1" onclick = "getrow ()"/>
<Input type = "hidden" name = "Fuj" id = "fuji1"/>
</TD>
<TD> Clothes size </TD>
<TD> Clothes </TD>
<TD> processing type </TD>
</Tr>
</Table>
<Table align = "center" border = "1" cellpadding = "4" cellspacing = "0" bordercolorlight = "#999999" bordercolordark = "# ffffff" style = "width: 95%; Word-break: Break-all ">
<Tr>
<TD align = "right">
<Input type = "button" name = "Submit" value = "add a line" onclick = "javascript: addrow ();"/>
<Input type = "button" name = "Submit" value = "delete a row" onclick = "javascript: delrow ();"/>
</TD>
</Tr>
</Table>
</Form>
</Body>
</Html>