We help IT Professionals succeed at work.

Select div not working in safari for Mac.

gabbs1
gabbs1 asked
on
Medium Priority
462 Views
Last Modified: 2008-03-17

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.
Comment
Watch Question

Commented:
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';}">
Commented:
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>

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Commented:
smaccari is correct. I miss it
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.