M
McKirahan
Firefox does not reflect selected option via innerHTML
How do I get Firefox to reflect selected option values?
<html>
<head>
<title>FFinner.htm</title>
<script type="text/javascript">
function clicks() {
document.getElementById("t1").value =
document.getElementById("s1").innerHTML;
}
</script>
</head>
<body>
<span id="s1">
<form>
<select>
<option value=""></option>
<option value="1">1</option>
</select>
<input type="button" value="Click" onclick="clicks()">
<textarea name="t1" id="t1" cols="80" rows="10"></textarea>
</form>
</span>
</body>
</html>
Selecting the first option (i.e. "1") then hitting "Click" gives:
(under IE)
<FORM>
<SELECT>
<OPTION value=""></OPTION>
<OPTION value=1 selected>1</OPTION>
</SELECT>
<INPUT onclick=clicks() type=button value=Click>
<TEXTAREA id=t1 name=t1 rows=10 cols=80></TEXTAREA>
</FORM>
(under FF)
<form>
<select>
<option value=""></option>
<option value="1">1</option>
</select>
<input value="Click" onclick="clicks()" type="button">
<textarea name="t1" id="t1" cols="80" rows="10"></textarea>
</form>
As you can see, IE shows that "1" is "selected" and FF does not.
Is there a fix? Thanks in advance.
P.S. "Big Al" posted a solution for input boxes at
http://forums.whirlpool.net.au/forum-replies-archive.cfm/385091.html
which "registers the changes with the DOM" via "setAttribute":
<input type="text" value="initial"
onblur="this.setAttribute('value',this.value);" />
So I guess I'm looking for something comparable for the <select> tag.
How do I get Firefox to reflect selected option values?
<html>
<head>
<title>FFinner.htm</title>
<script type="text/javascript">
function clicks() {
document.getElementById("t1").value =
document.getElementById("s1").innerHTML;
}
</script>
</head>
<body>
<span id="s1">
<form>
<select>
<option value=""></option>
<option value="1">1</option>
</select>
<input type="button" value="Click" onclick="clicks()">
<textarea name="t1" id="t1" cols="80" rows="10"></textarea>
</form>
</span>
</body>
</html>
Selecting the first option (i.e. "1") then hitting "Click" gives:
(under IE)
<FORM>
<SELECT>
<OPTION value=""></OPTION>
<OPTION value=1 selected>1</OPTION>
</SELECT>
<INPUT onclick=clicks() type=button value=Click>
<TEXTAREA id=t1 name=t1 rows=10 cols=80></TEXTAREA>
</FORM>
(under FF)
<form>
<select>
<option value=""></option>
<option value="1">1</option>
</select>
<input value="Click" onclick="clicks()" type="button">
<textarea name="t1" id="t1" cols="80" rows="10"></textarea>
</form>
As you can see, IE shows that "1" is "selected" and FF does not.
Is there a fix? Thanks in advance.
P.S. "Big Al" posted a solution for input boxes at
http://forums.whirlpool.net.au/forum-replies-archive.cfm/385091.html
which "registers the changes with the DOM" via "setAttribute":
<input type="text" value="initial"
onblur="this.setAttribute('value',this.value);" />
So I guess I'm looking for something comparable for the <select> tag.