Display Value

Discussion in 'JavaScript' started by aiden857, May 20, 2007.

  1. #1
    Hi all how do you display the value of a drop down list in a text field.

    Example :
    <select name="destin" id="destin" onchange="getPrice();">
    <option value="Dublin 1">Abbey St</option>
    <option value="Dublin 2">Amiens St</option>
    <option value="Dublin 3">Capel St</option>
    </select>

    I need to display the area code "dublin 1, 2, or 3" in a readonly textfield.

    Thanks and Top of the morning to ya. I wonder do people actually think the Irish say that.
     
    aiden857, May 20, 2007 IP
  2. wing

    wing Active Member

    Messages:
    210
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Try this...
    <script type="text/javascript">
    var Destination={
     1: "Dublin 1",
     2: "Dublin 2",
     3: "Dublin 3"
    };
    </script>
    
    
    <form>
    <select name="destin" onchange="p=Destination[this[this.selectedIndex].value]; this.form.areacode.value=(p)?p:'';">
      <option value="" selected> </option>
      <option value="1">Abbey St</option>
      <option value="2">Amiens St</option>
        <option value="3">Capel St</option>
    </select>
    <input type="text" name="areacode" value="" disabled>
    </form>
    
    Code (markup):
    You should be able add your call to getPrice():
    <select name="destin" onchange="p=objDestination[this[this.selectedIndex].value]; this.form.areacode.value=(p)?p:''; [B][COLOR="Red"]getPrice();[/COLOR][/B]">
    Code (markup):
    :)
     
    wing, May 20, 2007 IP
  3. aiden857

    aiden857 Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thats working fine.


    Thank you for your help.
     
    aiden857, May 20, 2007 IP