What u do if you want to give the option to user to take a new form element in a site you may be

  1. Use JS
  2. Use ajax
  3. Reload page by request to the server

most new user do the last one coz it is easy to use 1 or 2 you have to know a lot and also have to do a lot

But if you can do it by just add a attribute to to your form element

ya it is possible in HTML 5. let see it

copy this and RUN it on the Opera 9.6 (it will not works on the firefox or IE becouse only opera add some HTML5 tag on there one)


<!DOCTYPE html>
<html>
<head>
<title>Sample Order Form</title>
</head>
<body>
<form>
<table>
<thead>
<tr>
<th>Product</th>
<th>Quantity</th>
</tr>
</thead>
</tbody>
<tr id="order" <span style="color:#ff0000;">repeat="template" repeat-start="3"</span>>
<td><input type="text" name="row[order].product" value=""></td>
<td><input type="text" name="row[order].quantity" value="1"></td>
<td><button type="remove">Remove This Row</button></td>
</tr>
</tbody></table>

<<span style="color:#ff0000;">button type="add" template="order"</span>>Add Row</button>

<button type="submit">Submit</button>
</form>
</body>

</html>

the red marked two is the new a attribute do all of it what u do by a lot of strategy

1

now click on add row then  each time a new row will be added

2

Advertisements