I’m working on a project for Friends of Greyhounds creating a web-based interface and a database to manage the ex-racer greyhounds that they rescue and adopt.
I’ve been doing my development & testing on an iMac and have been using the Safari web browser. When I started testing the application on Firefox & Internet Explorer I discovered that a certain Javascript code would not work.
Here is what I wrote that worked with Safari, but failed to work in FireFox and Internet Explorer:
<input name="some_text" type="text" value="">
<select onchange="javascript:some_text.value=this.value;">
<option>CHOICE 1</option>
<option>CHOICE 2</option>
</select>
Here is the corrected code that works with Safari, Firefox and Internet Explorer:
<input name="some_text" id="some_text" type="text" value="">
<select onchange="javascript:document.getElementById('some_text').value=this.value;">
<option>CHOICE 1</option>
<option>CHOICE 2</option>
</select>
I understand what I did wrong. But Safari functioned like there were no errors in the Javascript. The selected value was assigned to the “some_text” text box and the error console did no show any messages at all.
