Hi all The following has 2 input elements (a selection list and an input field) and has 2 radio buttons that let the user select which input element they want to use, the unslelected element will get disabled. its working fine in IE6 and FF3 but not in sefari. <input name="radio" type="radio" value="x" checked="checked" onfocus="document.getElementById('menu1').disabled=false; document.getElementById('field1').disabled=true" /> <select id="menu1" name="menu1" > <option selected="selected">unnamed1</option> <option>unnamed2</option> <option>unnamed3</option> <option>unnamed4</option> </select> <input name="radio" type="radio" value="y" onfocus="document.getElementById('menu1').disabled=true; document.getElementById('field1').disabled=false"/> <input id="field1" name="field1" type="text" value="some text" disabled="disabled"/> <input type="submit" value="go" /> HTML: Anyone have any ideas whats going wrong?
Try like that: <form name="form1" action="" method=""> <input name="radio" type="radio" value="x" checked="checked" onClick="document.form1.menu1.disabled=false; document.form1.field1.disabled=true" /> <select id="menu1" name="menu1" > <option selected="selected">unnamed1</option> <option>unnamed2</option> <option>unnamed3</option> <option>unnamed4</option> </select> <input name="radio" type="radio" value="y" onClick="document.form1.menu1.disabled=true; document.form1.field1.disabled=false"/> <input id="field1" name="field1" type="text" value="some text" disabled="disabled"/> <input type="submit" value="go" /> </form> HTML:
thanks for the reply the problem with that I need my page to be XHTML strict complient, and the following isnt: it doesnt allown "name" in a form tag which is wht I was using document.getElementById('field1')
Use "document.forms['form1']" to refer form1: <form id="form1" action="" method=""> <input name="radio" type="radio" value="x" checked="checked" onClick="document.forms['form1'].menu1.disabled=false; document.forms['form1'].field1.disabled=true" /> <select id="menu1" name="menu1" > <option selected="selected">unnamed1</option> <option>unnamed2</option> <option>unnamed3</option> <option>unnamed4</option> </select> <input name="radio" type="radio" value="y" onClick="document.forms['form1'].menu1.disabled=true; document.forms['form1'].field1.disabled=false"/> <input id="field1" name="field1" type="text" value="some text" disabled="disabled"/> <input type="submit" value="go" /> </form> HTML: