Trying to get a value from a text box into a select-option when a checkbox is checked.
In IE, new empty options under the “one” option appear.
In Firefox and Chrome, nothing happens.
When uncommented, the alert() says “two,two” or similar for what’s put in the textbox.
Please tell me why is it not working.
[CODE]<html>
<head>
<title>
</title>
<script type=”text/javascript”>
function g(_p1)
{
if (_p1==’c1′ && document.f.ic.checked && document.f.it.value!=”)
{
var opt =document.createElement(“option”);
opt.text =document.f.it.value;
opt.value=opt.text; /*innerHTML*/
var sel =document.getElementById(“so”);
/*alert(opt.text+’,’+opt.value);*/
sel.appendChild(opt);
}
}
</script>
</head>
<body>
<form name=”f”>
<input name=”it” id=”it” type=”text” value=”two” size=”3″ maxlength=”3″>
<input name=”ic” id=”ic” type=”checkbox” value=”c1″ onclick=”g(‘c1’);”>
<select name=”so”>
<option value=”one”>
one
</option>
</select>
<input name=”s” id=”s” type=”submit” value=”*” onclick=”g(‘s’);”>
</form>
</body>
</html>