Placing the selection of a list field in a text field

Discussion in 'HTML' started by Jerry Manner, Jun 7, 2005.

  1. Jerry Manner

    Jerry Manner Guest

    Hi

    I have a field with a list of items. Like below:
    <select width="100" size="1" name="Industrielijst" style="font-family:
    Arial; font-size: 8pt">
    <option value="P1">Plants</option>
    <option value="P2">Software</option>
    <option value="P3">Hardware</option>
    <option value="P4">System</option>
    <option value="P5">Screens</option>
    </select>

    Above this field I have a text field, like this.
    <input type="text" name="T1" size="40">

    Is it possible when I make a selection to place that selection in the
    text field automatically? If so , how can I do that with javascript?

    Regards
    Jerry Manner, Jun 7, 2005
    #1
    1. Advertising

  2. In article <>,
    says...
    > Hi
    >
    > I have a field with a list of items. Like below:
    > <select width="100" size="1" name="Industrielijst" style="font-family:
    > Arial; font-size: 8pt">
    > <option value="P1">Plants</option>
    > <option value="P2">Software</option>
    > <option value="P3">Hardware</option>
    > <option value="P4">System</option>
    > <option value="P5">Screens</option>
    > </select>
    >
    > Above this field I have a text field, like this.
    > <input type="text" name="T1" size="40">
    >
    > Is it possible when I make a selection to place that selection in the
    > text field automatically? If so , how can I do that with javascript?
    >
    > Regards


    Untested:
    <select onchange="T1.value = this[this.selectedIndex].value;" ...

    --
    Hywel

    Kill the Crazy Frog
    http://www.petitiononline.com/crzyfrg/
    Hywel Jenkins, Jun 7, 2005
    #2
    1. Advertising

  3. Jerry Manner

    Jerry Manner Guest

    Hi

    I did what you said, but the text field shows the text "undefined" when
    I make a selection from the list. What must I change in the onchange
    code?


    Regards
    Jerry Manner, Jun 8, 2005
    #3
  4. Jerry Manner

    Jerry Manner Guest

    Maybe I should mention this. The select part of the code is inside a
    <div> tag.
    Jerry Manner, Jun 8, 2005
    #4
  5. Jerry Manner

    Mark Parnell Guest

    Previously in alt.html, Jerry Manner <> said:

    > Hi


    G'day.

    > I did what you said,


    I didn't say anything.

    > but the text field shows the text "undefined" when
    > I make a selection from the list. What must I change in the onchange
    > code?


    Impossible to say without a URL.

    --
    Mark Parnell
    http://www.clarkecomputers.com.au
    alt.html FAQ :: http://html-faq.com/
    Mark Parnell, Jun 8, 2005
    #5
  6. Hywel Jenkins wrote:
    > In article <>,
    > says...
    >
    >>Hi
    >>
    >>I have a field with a list of items. Like below:
    >><select width="100" size="1" name="Industrielijst" style="font-family:
    >>Arial; font-size: 8pt">
    >><option value="P1">Plants</option>
    >><option value="P2">Software</option>
    >><option value="P3">Hardware</option>
    >><option value="P4">System</option>
    >><option value="P5">Screens</option>
    >></select>
    >>
    >>Above this field I have a text field, like this.
    >><input type="text" name="T1" size="40">
    >>
    >>Is it possible when I make a selection to place that selection in the
    >>text field automatically? If so , how can I do that with javascript?
    >>
    >>Regards

    >
    >
    > Untested:
    > <select onchange="T1.value = this[this.selectedIndex].value;" ...
    >

    Couple things here..

    1. Wrap the form elements in a form, else grabing T1 becomes very difficult
    2. This DOES require Javascript to be ENABLED to work
    3. The code:

    <form>
    <select width="100" size="1" name="Industrielijst" style="font-family:
    Arial; font-size: 8pt"
    onchange="this.form.T1.value=this.options[selectedIndex].value">
    <option value="P1">Plants</option>
    <option value="P2">Software</option>
    <option value="P3">Hardware</option>
    <option value="P4">System</option>
    <option value="P5">Screens</option>
    </select>
    <input type="text" name="T1" size="40">
    </form>

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Jun 9, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ray Stevens
    Replies:
    4
    Views:
    4,401
    Ray Stevens
    Apr 26, 2005
  2. Andrew Crowe
    Replies:
    1
    Views:
    4,444
    Andrew Crowe
    Sep 13, 2004
  3. curiousity

    HOWTO autopost the selection list upon selection

    curiousity, Nov 21, 2003, in forum: ASP .Net Mobile
    Replies:
    0
    Views:
    259
    curiousity
    Nov 21, 2003
  4. Loebb
    Replies:
    0
    Views:
    192
    Loebb
    Feb 23, 2004
  5. Replies:
    13
    Views:
    247
    Dr John Stockton
    Jan 28, 2005
Loading...

Share This Page