Results 1 to 3 of 3

Thread: Newbie onchange event problem

  1. #1
    Join Date
    Apr 2009

    Newbie onchange event problem

    Yay my first post!

    Firefox 3 and IE8 are giving me different values for an onchange event attached to a form select box. All I'm trying to do is detect when a user chooses an item in a select box. If he choses the empty item I want my "Next" button disabled. If he choses a valid name, then I want the "Next" button enabled. Here's the relevant code.

    <script type="text/javascript">
    function toggleButton() {
    	if ((document.getElementsByName("T1")[0].value == "") && (document.getElementsByName("T2")[0].value == ""))
    		{document.getElementsByName("nextBtn")[0].disabled = true;}
    		{document.getElementsByName("nextBtn")[0].disabled = false;}
    And the associated HTML

    HTML Code:
    <select name="T1" onChange="toggleButton()"><option></option><option>Mrs Amber</option></select
    When toggleButton() fires after an onchange event the two .value calls return the current correct values. When I do this in IE8, the .value calls are always empty (I assume "").

    Can someone fill me in on what IE8's doing and how I can resolve this? (And if you happen to see any general coding improvements, this ex Smalltalk/newbie Javascript developer would welcome them. )

    Thank you in advance.

  2. #2
    Join Date
    May 2006
    Odenton, MD
    try including the value attribute to html option. on some browsers when the value is missing it use the text as the value. probably this isn't supposed to happen. if that is true, then that is the case of firefox3 and msie8.
    my mom is javascript, dad is javascripter, granpa is javascriptor, and my little sister is javasRidiculous.
    my nature language is javascript, then come spanish and english -- me

  3. #3
    Join Date
    Apr 2009
    Problem Solved! Thank You.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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