Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Put value of a selected item in Listbox in a text field

Reply
Thread Tools

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

 
 
Eddy Scheire
Guest
Posts: n/a
 
      01-31-2005
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


 
Reply With Quote
 
 
 
 
Eddy Scheire
Guest
Posts: n/a
 
      01-31-2005
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" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> "Eddy Scheire" <(E-Mail Removed)> wrote in message
> news:41fd7c7c$0$314$(E-Mail Removed)...
> > 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=do cument.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>
>
>



 
Reply With Quote
 
 
 
 
똥강아지
Guest
Posts: n/a
 
      01-31-2005
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 : http://www.velocityreviews.com/forums/(E-Mail Removed)
blog : http://ddongdog.egloos.com


"Eddy Scheire" <(E-Mail Removed)> wrote in message
news:41fd7c7c$0$314$(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Dave Anderson
Guest
Posts: n/a
 
      01-31-2005
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.


 
Reply With Quote
 
Eddy Scheire
Guest
Posts: n/a
 
      01-31-2005
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=do cument.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" <(E-Mail Removed)> schreef in bericht
news:(E-Mail Removed)...
> "Eddy Scheire" <(E-Mail Removed)> wrote in message
> news:41fd7c7c$0$314$(E-Mail Removed)...
> > 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=do cument.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>
>
>



 
Reply With Quote
 
Phill. W
Guest
Posts: n/a
 
      01-31-2005
"Eddy Scheire" <(E-Mail Removed)> wrote in message
news:41fe437d$0$2417$(E-Mail Removed)...
> I get an error on this line :
> Response.Write "<SELECT ALIGN='center' name="Band" id="Band"
>

onchange="document.getElementById('Desc').value=do cument.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.


 
Reply With Quote
 
McKirahan
Guest
Posts: n/a
 
      01-31-2005
"Eddy Scheire" <(E-Mail Removed)> wrote in message
news:41fe437d$0$2417$(E-Mail Removed)...
> 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=do cument.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=do cument.getElementByID('Ban
d').value'>"


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to pass selected item from listbox of one form to text box of other form chintan Software 0 12-19-2007 11:38 AM
Retrieving the value of an Selected Item from a Listbox widget doni Perl Misc 1 03-14-2007 06:23 PM
Unable to get the selected item value of Listbox in codebehind akula.sandeepkumar ASP .Net 0 11-02-2006 01:04 PM
Return a value of the selected item from a dropdown listbox acord Javascript 1 03-09-2006 11:42 AM
autofill text field after listbox item selected Dave ASP General 1 01-24-2005 10:21 PM



Advertisments