By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,795 Members | 1,660 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,795 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Jul 22 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
"Eddy Scheire" <ed**********@skynet.be> wrote in message
news:41*********************@news.skynet.be...
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>
Jul 22 '05 #2

P: n/a
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" <Ne**@McKirahan.com> schreef in bericht
news:ie********************@comcast.com...
"Eddy Scheire" <ed**********@skynet.be> wrote in message
news:41*********************@news.skynet.be...
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>

Jul 22 '05 #3

P: n/a
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 : sa*****@hotmail.com
blog : http://ddongdog.egloos.com
"Eddy Scheire" <ed**********@skynet.be> wrote in message
news:41*********************@news.skynet.be...
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

Jul 22 '05 #4

P: n/a
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.
Jul 22 '05 #5

P: n/a
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" <Ne**@McKirahan.com> schreef in bericht
news:ie********************@comcast.com...
"Eddy Scheire" <ed**********@skynet.be> wrote in message
news:41*********************@news.skynet.be...
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>

Jul 22 '05 #6

P: n/a
"Eddy Scheire" <ed**********@skynet.be> wrote in message
news:41**********************@news.skynet.be...
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.
Jul 22 '05 #7

P: n/a
"Eddy Scheire" <ed**********@skynet.be> wrote in message
news:41**********************@news.skynet.be...
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'>"
Jul 22 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.