Put value of a selected item in Listbox in a text field

Discussion in 'ASP General' started by Eddy Scheire, Jan 31, 2005.

  1. Eddy Scheire

    Eddy Scheire Guest

    Hi all,

    I've got this listbox and this text field on an ASP page. Now I want the
    item I click on in the listbox to appear in the text field and I can't find
    the code nowhere for what seems to me such an easy thing to do.

    Any help would be appreciated.

    Thanx in advance,
    Eddy
     
    Eddy Scheire, Jan 31, 2005
    #1
    1. Advertising

  2. Eddy Scheire

    Eddy Scheire Guest

    It's a listbox that's built by reading a Database in a loop in a VBScript
    and fill it up with every record found

    Response.Write "<OPTION VALUE='" & RSItem("Item_Nr") & "'>" & RSItem("Naam")



    "McKirahan" <> schreef in bericht
    news:...
    > "Eddy Scheire" <> wrote in message
    > news:41fd7c7c$0$314$...
    > > Hi all,
    > >
    > > I've got this listbox and this text field on an ASP page. Now I want the
    > > item I click on in the listbox to appear in the text field and I can't

    > find
    > > the code nowhere for what seems to me such an easy thing to do.
    > >
    > > Any help would be appreciated.
    > >
    > > Thanx in advance,
    > > Eddy
    > >

    >
    > Is this a class assignment?
    > I answered the same question in another ng last week.
    >
    > If by "listbox" you mean "selection list" then ...
    >
    > Will this help? Watch for word-wrap.
    >
    > <html>
    > <head>
    > <title>sel2text.htm</title>
    > </head>
    > <body>
    > <form name="form1">
    > <b>Part Number : </b>
    > <select name="Part" id="Part"
    >
    >

    onchange="document.getElementById('Desc').value=document.getElementById('Par
    > t').value">
    > <option value="">
    > <option value="Product 1">123
    > <option value="Product 2">456
    > <option value="Product 3">789
    > </select>
    > <br><b>Product Description : </b>
    > <input type="text" name="Desc" id="Desc">
    > </body>
    > </html>
    >
    >
     
    Eddy Scheire, Jan 31, 2005
    #2
    1. Advertising

  3. in my case I create this..

    function CheckEtc(str) {
    if (document.getElementById(str + 'Check').checked)
    {
    document.getElementById(str + '1').style.display = 'none';
    document.getElementById(str + '2').style.display = 'inline';
    }
    else
    {
    document.getElementById(str + '1').style.display = 'inline';
    document.getElementById(str + '2').style.display = 'none';
    }
    }

    <tr>
    <td width="121" bgcolor="#E1E1E1">ºÐ·ù</td>
    <td colspan="3"><select id="propart1" class="memr"
    style="width: 150px;" style="display: none;"><option
    value=»ýÈ°±âȹ>»ýÈ°±âȹ</option><option
    value=¾Ç±â±âÃÊ>¾Ç±â±âÃÊ</option><option value=¿µ»ó>¿µ»ó</option><option
    value=ÈüÇÕ>ÈüÇÕ</option></select><input id="propart2" name="propart2"
    type="text" class="memr" style="display: inline;" style="width: 150px;"
    maxlength="50">
    <input id="propartCheck" type="checkbox"
    name="CheckEct" onClick="CheckEtc('propart');" checked>
    ±âŸ
    </td>
    </tr>

    --
    JinHyung Lee
    msn :
    blog : http://ddongdog.egloos.com


    "Eddy Scheire" <> wrote in message
    news:41fd7c7c$0$314$...
    > Hi all,
    >
    > I've got this listbox and this text field on an ASP page. Now I want the
    > item I click on in the listbox to appear in the text field and I can't

    find
    > the code nowhere for what seems to me such an easy thing to do.
    >
    > Any help would be appreciated.
    >
    > Thanx in advance,
    > Eddy
    >
    >
     
    ¶Ë°­¾ÆÁö, Jan 31, 2005
    #3
  4. Eddy Scheire wrote:
    > I've got this listbox and this text field on an ASP page. Now I want
    > the item I click on in the listbox to appear in the text field and I
    > can't find the code nowhere for what seems to me such an easy thing
    > to do.


    Like this?

    <select
    onchange="this.form.TARGETFIELD.value=this[this.selectedIndex].value" ...>



    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms. Please do not contact
    me directly or ask me to contact you directly for assistance. If your
    question is worth asking, it's worth posting.
     
    Dave Anderson, Jan 31, 2005
    #4
  5. Eddy Scheire

    Eddy Scheire Guest

    This works indeed in the HTML part of this ASP-page but not in the VBScript
    part :

    Response.Write "<H3 ALIGN='center'>Artists Found for Category : </H3>"
    Response.Write "<H3 ALIGN='center' Kategorie></H3>"

    I get an error on this line :
    Response.Write "<SELECT ALIGN='center' name="Band" id="Band"
    onchange="document.getElementById('Desc').value=document.getElementByID('Ban
    d').value">"

    Do While Not RS.EOF
    Response.Write "<OPTION VALUE='" & RS("Nummer") & "'>" & RS("Naam")
    RS.MoveNext
    Loop
    Response.Write "</SELECT>"

    Eddy

    "McKirahan" <> schreef in bericht
    news:...
    > "Eddy Scheire" <> wrote in message
    > news:41fd7c7c$0$314$...
    > > Hi all,
    > >
    > > I've got this listbox and this text field on an ASP page. Now I want the
    > > item I click on in the listbox to appear in the text field and I can't

    > find
    > > the code nowhere for what seems to me such an easy thing to do.
    > >
    > > Any help would be appreciated.
    > >
    > > Thanx in advance,
    > > Eddy
    > >

    >
    > Is this a class assignment?
    > I answered the same question in another ng last week.
    >
    > If by "listbox" you mean "selection list" then ...
    >
    > Will this help? Watch for word-wrap.
    >
    > <html>
    > <head>
    > <title>sel2text.htm</title>
    > </head>
    > <body>
    > <form name="form1">
    > <b>Part Number : </b>
    > <select name="Part" id="Part"
    >
    >

    onchange="document.getElementById('Desc').value=document.getElementById('Par
    > t').value">
    > <option value="">
    > <option value="Product 1">123
    > <option value="Product 2">456
    > <option value="Product 3">789
    > </select>
    > <br><b>Product Description : </b>
    > <input type="text" name="Desc" id="Desc">
    > </body>
    > </html>
    >
    >
     
    Eddy Scheire, Jan 31, 2005
    #5
  6. Eddy Scheire

    Phill. W Guest

    "Eddy Scheire" <> wrote in message
    news:41fe437d$0$2417$...
    > I get an error on this line :
    > Response.Write "<SELECT ALIGN='center' name="Band" id="Band"
    >

    onchange="document.getElementById('Desc').value=document.getElementByID('Ban
    > d').value">"


    Don't you just /love/ quotes? (line-breaks for clarity, only)

    Response.Write "<select " _
    & "align='center' " _
    & "name='Band' " _
    & "id='Band' " _
    & "onchange=""document.getElementById( 'Desc' ).value " _
    & "= document.getElementByID( 'Band' ).value"" " _
    & ">"

    HTH,
    Phill W.
     
    Phill. W, Jan 31, 2005
    #6
  7. Eddy Scheire

    McKirahan Guest

    "Eddy Scheire" <> wrote in message
    news:41fe437d$0$2417$...
    > This works indeed in the HTML part of this ASP-page but not in the

    VBScript
    > part :
    >
    > Response.Write "<H3 ALIGN='center'>Artists Found for Category : </H3>"
    > Response.Write "<H3 ALIGN='center' Kategorie></H3>"
    >
    > I get an error on this line :
    > Response.Write "<SELECT ALIGN='center' name="Band" id="Band"
    >

    onchange="document.getElementById('Desc').value=document.getElementByID('Ban
    > d').value">"
    >
    > Do While Not RS.EOF
    > Response.Write "<OPTION VALUE='" & RS("Nummer") & "'>" & RS("Naam")
    > RS.MoveNext
    > Loop
    > Response.Write "</SELECT>"
    >
    > Eddy


    [snip]

    I would expect that you would.

    You mixed single and double quotation marks.

    Try this:

    Response.Write "<SELECT ALIGN='center' name='Band' id='Band'
    onchange='document.getElementById('Desc').value=document.getElementByID('Ban
    d').value'>"
     
    McKirahan, Jan 31, 2005
    #7
    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. akula.sandeepkumar
    Replies:
    0
    Views:
    3,511
    akula.sandeepkumar
    Nov 2, 2006
  2. Dave
    Replies:
    1
    Views:
    160
    Bob Barrows [MVP]
    Jan 24, 2005
  3. Sarah West

    default selected item and field value

    Sarah West, Nov 3, 2003, in forum: Javascript
    Replies:
    3
    Views:
    118
    Richard Cornford
    Nov 4, 2003
  4. doni
    Replies:
    1
    Views:
    108
  5. acord
    Replies:
    1
    Views:
    113
    Erwin Moller
    Mar 9, 2006
Loading...

Share This Page