Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Javascript
Firefox does not reflect selected option via innerHTML
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="McKirahan, post: 4902657"] [snip] I got a solution from "Big Al". <html> <head> <title>FFinner.htm</title> <script type="text/javascript"> function blurs(that) { if (that.type == "select-one") { for (var i=0; i<that.options.length; i++) { if (i == that.selectedIndex) { that.options[that.selectedIndex].setAttribute("selected","selected"); } } } else if (that.type == "text") { that.setAttribute("value",that.value); } } function clicks() { document.getElementById('t').value = document.getElementById("d").innerHTML; } </script> </head> <body> <div id="d"> <form> <select onblur="blurs(this)"> <option value=""></option> <option value="1">1</option> <option value="2">2</option> </select> <select> <option value=""></option> <option value="1">1</option> <option value="2">2</option> </select> <input type="text" value="" onblur="blurs(this)"> <input type="text" value=""> <input type="button" value="Click" onclick="clicks()"> <br><textarea name="t" id="t" cols="80" rows="10"></textarea> </form> </div> </body> </html> Selecting "1" and "2" and entering "3" and "4" gives the following in the <textarea>; (line breaks added): 1). Results under IE: <FORM> <SELECT onblur=blurs(this)> <OPTION value=""></OPTION> <OPTION value=1 selected>1</OPTION> <OPTION value=2>2</OPTION> </SELECT> <SELECT> <OPTION value=""></OPTION> <OPTION value=1>1</OPTION> <OPTION value=2 selected>2</OPTION> </SELECT> <INPUT onblur=blurs(this) value=3> <INPUT value=4> <INPUT onclick=clicks() type=button value=Click> <BR> <TEXTAREA id=t name=t rows=10 cols=80> </TEXTAREA> </FORM> 3. Results under FF: <form> <select onblur="blurs(this)"> <option value=""></option> <option selected="selected" value="1">1</option> <option value="2">2</option> </select> <select> <option value=""></option> <option value="1">1</option> <option value="2">2</option> </select> <input value="3" onblur="blurs(this)" type="text"> <input value="" type="text"> <input value="Click" onclick="clicks()" type="button"> <br><textarea name="t" id="t" cols="80" rows="10"> </textarea> </form> As can be seen above, under Firefox: "2" is not selected and "4" is not the value because "onblur=" was not executed. The "function blurs()" is used to "register the selected option with the DOM". Thanks for everyone's input. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Javascript
Firefox does not reflect selected option via innerHTML
Top