61 users online (1 members and 60 guests)  


  Results 1 to 2 of 2

Related

  1. Populating Form Field from URL    Forum: HTML Forum
    Replies: 0
  2. The sum of two fields    Forum: Website Scripts Forum
    Replies: 4
  3. emailing forms excluding empty fields    Forum: HTML Forum
    Replies: 2
  4. The sum of two fields    Forum: HTML Forum
    Replies: 1
  5. Pre Populatated Fields    Forum: HTML Forum
    Replies: 1
  1. #1
    Mr Kay's Avatar
    New User

    Status
    Offline
    Join Date
    Feb 2007
    Posts
    4

    Forms & populating fields

    Hi, I'm a complete novice to Javascript and need help with populating a field after a user makes a selection from a drop down list.
    Basically it involves the following code:-
    Code:
    <select name="q2_SelectPhone" id="q2"
    onchange="document.ex.q3_Wewillpayyou.value = document.ex.q2_SelectPhone.options[document.ex.q2_SelectPhone.selectedIndex].value;">
    <!--<option value="100" selected="selected">full</option>-->
    <option value="1.67">OT152</option>
    <option value="1.67">OT155</option>
    <option value="0.61">OT301</option>
    <option value="1.14">OT331</option>
    <option value="1.14">OT355A</option>
    </select> </td>
    When the user makes their selection I want a field to be populated by the value (say 1.14 if OT355A is selected from the above list) not the selection visible to the user.
    The code which populates the field is shown below:-
    Code:
    <label for="q3"><font size="+2">We will pay you </font></label> 
    <input type="text" size="20" name="q3_Wewillpayyou" id="q3"
    onblur="document.ex.q3_Wewillpayyou.value = document.ex.q2_SelectPhone.options[document.ex.q2_SelectPhone.selectedIndex].value;"
    Thanks in advance.
    Last edited by DeadMeatGF; 02-27-2007 at 09:38 AM. Reason: Added Code tags

  2. #2
    ALL's Avatar
    Super Dooper Nerd

    Status
    Offline
    Join Date
    Feb 2005
    Location
    localhost
    Posts
    382

    Re: Forms & populating fields

    try something like:

    HTML Code:
    <select name="q2_SelectPhone" id="q2"
    onchange="document.getElementById('q3').value = this.value">
    <!--<option value="100" selected="selected">full</option>-->
    <option value="1.67">OT152</option>
    <option value="1.67">OT155</option>
    <option value="0.61">OT301</option>
    <option value="1.14">OT331</option>
    <option value="1.14">OT355A</option>
    </select>



Tags for this Thread