Results 1 to 3 of 3

Thread: Javascript and IE 9 issue

  1. #1
    Join Date
    Oct 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Javascript and IE 9 issue

    Hello,

    I'm having a problem with this bit of javascript code:

    Code:
    <script language="javascript">
    function myna(){
    		if(document.test.na.checked){
    		  document.getElementById("start").style.visibility = "hidden";
    		  document.getElementById("end").style.visibility = "hidden";
    		  document.test.start_hour[0].selected = true;
    		  document.test.start_minute[0].selected = true;
    		  document.test.start_half[0].selected = true;
    		  document.test.end_hour[0].selected = true;
    		  document.test.end_minute[0].selected = true;
    		  document.test.end_half[0].selected = true;
    		}
    		else{
    		  document.getElementById("start").style.visibility = "visible";
    		  document.getElementById("end").style.visibility = "visible";
    		  
    		}
    	  }
    </script>
    It works fine in both Firefox and Chrome but not in IE 9. I would like the Start and End input fields to be hidden when the N/A checkbox is checked. However, in IE 9 the Start and End input fields are not hidden when I check the N/A checkbox. I do notice that if I click on another area of the page, the Start and End input fields become hidden. How do I get the code to properly work on IE 9?

    Thanks!

  2. #2
    Join Date
    Jul 2008
    Posts
    128
    Thanks
    0
    Thanked 17 Times in 16 Posts

    Default

    Quote Originally Posted by mgva View Post
    Code:
    		if(document.test.na.checked)
    Forms should not be addressed by their name attribute, not least because they shouldn't have one.

    Since you haven't shown the calling code, I would guess that you're using the onchange event, when what you need is onclick.

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The only thing I can think of is that myna is run onchange of something. IE 9 may be waiting for you to click elsewhere (draw focus away from the changed element) before registering the onchange event. It could easily be something else or that and something else, or several things. To really tell we would need to see the whole page.

    If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. Javascript issue
    By saicvs in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 09-30-2011, 12:35 PM
  2. Javascript On Load Issue?
    By SChaput in forum JavaScript
    Replies: 2
    Last Post: 06-16-2010, 01:34 PM
  3. JavaScript (maybe CSS) Issue with IE7
    By firefly_x in forum JavaScript
    Replies: 6
    Last Post: 03-30-2009, 09:12 AM
  4. Javascript issue in scroller
    By iamwonton in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 12-04-2006, 07:24 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •