You can add custom parameters and variables required during the increase or decrease process, such as $ ("table"). dynamicaddremover ({param1: "param1", param2: "param2 "});
For example, options. param1.
. The root container must have a unique id and must be unique at the specified time. If multiple modules (multiple root containers) need to be used: $ ("# table1 "). dynamicaddremover (), $ ("# table2 "). dynamicaddremover () and so on.
The id and name in the newly added control are not updated. If you have special business needs, add the business logic for generating the new id in addedevent.
Instance 1
<? Xml version = "1.0" encoding = "iso-8859-1"?>
<Html>
<Head>
<Title> </title>
<Script language = "webpage effects" src = "jquery-1.4.2.min. webpage effects"> </script>
<Script language = "javascript" src = "dynamicaddremover. js"> </script>
<Script language = "javascript">
$ (Function (){
$ ("# Table1"). dynamicaddremover ({
Addedevent: function (newctl, options ){
// Clear the textbox.
Newctl. find (": text"). val ('');
If ($ ("table"). size ()> 5)
{
// Hide the add button.
Newctl. find ("img [id $ = '" + options. adderid + "']"). hide ();
}
},
Removedevent: function (prevctl, nextctl, options ){
If ($ ("table"). size () <= 5)
{
// Show the add button.
$ ("Table: last"). find ("img [id $ = '" + options. adderid + "']"). show ();
}
}
});
});
</Script>
</Head>
<Body>
<Table id = 'table1'>
<Tr>
<Td>
<Select>
<Option value = "volvo"> volvo </option>
<Option value = "saab"> saab </option>
<Option value = "opel"> opel </option>
<Option value = "audi"> audi </option>
</Select>
<Input type = "text" name = "text1" id = "text1" value = "text"> </input>
<Button type = "button" name = "btn1" value = "btn1" id = "btn1"> button </button>
</Td>
</Tr>
</Table>
</Body>
</Html>
Instance 2
<? Xml version = "1.0" encoding = "iso-8859-1"?>
<Html>
<Head>
<Title> </title>
<Script language = "javascript" src = "jquery-1.4.2.min.js"> </script>
<Script language = "javascript" src = "dynamicaddremover. js"> </script>
<Script language = "javascript">
$ (Function (){
$ ("Table"). dynamicaddremover ();
});
</Script>
</Head>
<Body>
<Table>
<Tr>
<Td>
<Select>
<Option value = "volvo"> volvo </option>
<Option value = "saab"> saab </option>
<Option value = "opel"> opel </option>
<Option value = "audi"> audi </option>
</Select>
<Input type = "text" name = "text1" id = "text1" value = "text"> </input>
<Button type = "button" name = "btn1" value = "btn1" id = "btn1"> button </button>
</Td>
</Tr>
</Table>
</Body>
</Html>
Add controls, such as the file upload box and the input box, and use the two examples above for instance. However, the instance is an unlimited one that can control the number of controls added, and the deletion control is added.