AM using 2 buttons in my Page. Add and Remove
If I press Add, a row of text box and a list box should be added.
Remove is used to Undo the Previous operation.
The code I have used is,
var cellRight = row.insertCell(5);
var el = document.createElement('input');
el.setAttribute('type', 'text');
el.setAttribute('name', 'txtRow');
el.setAttribute('size', '15');
cellRight.appendChild(el);
This works well if I use only text box. To add a List box
var cellRight = row.insertCell(6);
var el = document.createElement('input');
el.setAttribute('type', 'select');
el.setAttribute('size', '15');
el.setAttribute('method','onclick');
cellRight.appendChild(el);
I wrote this code, but when I press the “Add” button, only Text Boxes instead of list boxes.
Is my code correct?
There is no
<input type="select">. You need to create aselectelement and addoptionsub-elements.Something along these lines perhaps:
Beware, dry-coded, ymmv.