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

E

Eddy Scheire

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
 
E

Eddy Scheire

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")
 

¶Ë°­¾ÆÁö

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>
 
D

Dave Anderson

Eddy said:
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.
 
E

Eddy Scheire

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
 
P

Phill. W

Eddy Scheire said:
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.
 
M

McKirahan

Eddy Scheire said:
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'>"
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top