Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript not working in Safari

Status
Not open for further replies.

buddyrich2

Technical User
Apr 12, 2006
87
US
I have some javascript that changes some html based on some radio button choices. Works great in IE, but in Safari doesn't work; in fact none of the rest of the form after that is displayed.

Here is the code:
Code:
<script type="text/javascript">
	function SetHTML1(type) {
		document.getElementById("a1").style.display = "none"
		document.getElementById("b1").style.display = "none"
                                
		// Using style.display="block" instead of style.display="" leaves a carriage return
		document.getElementById(type).style.display = ""
	}
</script>

<INPUT TYPE="RADIO" NAME="insurance_yn" VALUE="Y" CHECKED onClick="SetHTML1('a1')">Yes&nbsp;<INPUT TYPE="RADIO" NAME="insurance_yn" VALUE ="N" onClick="SetHTML1('b1')">No</td></tr></table>

<span id="a1" style="">Blah blah blah</span>

<span id="b1" style="display:none">blah blah option 2</span>
Can anyone help me? Thanks in advance!
 
I included "Inline" now but still does not work in Safari. Could it be something else?

Thanks.
 
I took your posted code, and completed the start of the table like so:
Code:
<script type="text/javascript">
    function SetHTML1(type) {
        document.getElementById("a1").style.display = "none" 
        document.getElementById("b1").style.display = "none" 
                                
        document.getElementById(type).style.display = "" 
    }
</script>

<table><tr><td>
<INPUT TYPE="RADIO" NAME="insurance_yn" VALUE="Y" CHECKED onClick="SetHTML1('a1')">Yes&nbsp;<INPUT TYPE="RADIO" NAME="insurance_yn" VALUE ="N" onClick="SetHTML1('b1')">No</td></tr></table>

<span id="a1" style="">Blah blah blah</span>

<span id="b1" style="display:none">blah blah option 2</span>

and I have no problems with the value changing in Safari 3.1.2 on the Mac ...

Is this your whole code or did you just cut/paste certain parts? If the latter is the case, you're better off posting the whole code snippet instead of parts of it.

Greg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top