• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 450
  • Last Modified:

Select div not working in safari for Mac.


I have the following:

<select name="country" onChange="javascript:if(this.options[this.selectedIndex].value != 'United Kingdom'){ document.all.warning7.style.display = 'block';}else{document.all.warning7.style.display = 'none';}">
                                          <option>Please select</option>
                          <option value="United Kingdom">United Kingdom</option>
...
</select>

<div id="warning7" style=" display:none;">
my text.
</div>

Which works fine in IE and Firefox etc.. but in Safari for Mac the div tag doesn't apear.
0
gabbs1
Asked:
gabbs1
  • 2
1 Solution
 
hongjunCommented:
try

<select name="country" onChange="javascript:if(this.options[this.selectedIndex].value != 'United Kingdom'){ document.all.warning7.style.display = '';}else{document.all.warning7.style.display = 'none';}">
0
 
smaccariCommented:
The document.all is IE specific.
You should use document.getElementById instead (that will work even on IE though).

So your SELECT will become :

<select name="country" onChange="javascript:if(this.options[this.selectedIndex].value != 'United Kingdom'){ document.getElementById('warning7').style.display = 'block';}else{document.getElementById('warning7').style.display = 'none';}">
                                          <option>Please select</option>
                      <option value="United Kingdom">United Kingdom</option>
...
</select>
0
 
hongjunCommented:
smaccari is correct. I miss it
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now