Results 1 to 4 of 4
  1. #1

    onChange with 2 values not working in FireFox


    I'm trying to do an onchange in the dropdown options but unfortunately it only works in IE and not in firefox, how is it possible to make it work in firefox?

    Part of Code:

    <form method="post" action="*****.php">
    <SELECT NAME='country' class='inputbox' onChange="areacode.value=this[this.selectedIndex].value2">
             <OPTION value2="" VALUE=''>---- Select here ----</OPTION>
                 <option value2="93" value="1" >Afghanistan</option>
    <option value2="355" value="2" >Albania</option>
    <option value2="213" value="3" >Algeria</option>
    <option value2="684" value="4" >American Samoa</option>
    <option value2="376" value="5" >Andorra</option>
    <option value2="244" value="6" >Angola</option>
    <option value2="1264" value="7" >Anguilla</option>
    <option value2="672" value="8" >Antarctica</option>
    <option value2="1268" value="9" >Antigua And Barbuda</option>
    <option value2="54" value="10" >Argentina</option>
    <option value2="374" value="11" >Armenia</option>
    <option value2="297" value="12" >Aruba</option>
    <input type="text" size="2" name="areacode" DISABLED>
    I need the value2 to be entered in the textbox and not necessary to be submitted to the form, but the value should be submitted, when I try this code on Firefox on each select I get undefined, but it works on IE. So what's the solution for firefox. Please help


  2. #2
    document.getElementById('areacode'). instead of just areacode.

    and add id="areacode" in the tag

    i'm pretty sure that'll work

  3. #3
    Join Date
    Jun 2004
    Bay Area -USA
    hehe I had this same problem my friend.

    Here was my solution:
    PHP Code:
    <script language="JavaScript">
    selecteditem document.forms[0].areacode.selectedIndex ;
    selval document.forms[0].areacode.optionsselecteditem ].value ;
    document.forms[0].value2.value selval;
    <form method="post" action="*****.php">
    <SELECT NAME='country' class='inputbox' onChange="updatew3()">
     <OPTION name='value2' VALUE=''>---- Select here ----</OPTION>
    Hope that works
    <<< Please see Forum Guidelines for signature setup. >>>

  4. #4
    Thanks for your reply, But actually it didn't work.

    I got this error upon selecting an option:
    document.forms.0.areacode.options is null or not an object.

    Waiting for your reply.

Posting Permissions

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