D
domas
Hi,
I can't get my semi-dynamic form to work. Maybe you could help.
I've got a simple form with a select box. And a button that, when
clicked, creates another copy if the select box and places it in a
specified div.
<select name="tst[]" id="tst">
<option value=1>1</option>
<option value=2>6</option>
</select>
<input type="button" value="Add"
onclick="createNew(document.getElementById('tst'),
document.getElementById('pasl'));">
here's the script:
function createNew(sel, div) {
spNew = document.createElement("span");
selNew = sel.cloneNode(true);
spNew.appendChild(selNew);
spNew.innerHTML = spNew.innerHTML + "<input type=\"button\"
value=\"Drop\"
onclick=\"alert(\'ok\');\" id=\"btn\" >";
sp = div.appendChild(spNew);
};
It works ok in IE, but under firefox, the value of the new select is
not submitted. The div that I add the select to is a child of the form,
so this should work, right? What could I have missed?
Another question would be: what is the correct way to specify the event
for a dinamically created button?
Thanks in advance,
Domas
I can't get my semi-dynamic form to work. Maybe you could help.
I've got a simple form with a select box. And a button that, when
clicked, creates another copy if the select box and places it in a
specified div.
<select name="tst[]" id="tst">
<option value=1>1</option>
<option value=2>6</option>
</select>
<input type="button" value="Add"
onclick="createNew(document.getElementById('tst'),
document.getElementById('pasl'));">
here's the script:
function createNew(sel, div) {
spNew = document.createElement("span");
selNew = sel.cloneNode(true);
spNew.appendChild(selNew);
spNew.innerHTML = spNew.innerHTML + "<input type=\"button\"
value=\"Drop\"
onclick=\"alert(\'ok\');\" id=\"btn\" >";
sp = div.appendChild(spNew);
};
It works ok in IE, but under firefox, the value of the new select is
not submitted. The div that I add the select to is a child of the form,
so this should work, right? What could I have missed?
Another question would be: what is the correct way to specify the event
for a dinamically created button?
Thanks in advance,
Domas