473,417 Members | 1,566 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,417 software developers and data experts.

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

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
7 3278
"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
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
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
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
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
"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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Coz | last post by:
Hi all, I'm looking for help again!!! I have been writing a page to update a database but now have another 'silly' problem with listbox's...Grrr... I'm trying to populate the list box with...
5
by: Lukelrc | last post by:
Hi, I have a dynamically created listbox. I'm trying to get one of the options selected according to a passed value. This is what i have: <select name="txtTheme" id="txtTheme"> ...
16
by: cwizard | last post by:
I'm calling on a function from within this form, and there are values set but every time it gets called I get slammed with a run time error... document.frmKitAmount.txtTotalKitValue is null or not...
2
by: Wishing I was skiing mom | last post by:
Newbie to VB .NET. My solution contains an item maintenance screen, one of the fields on the screen is an item status, this field is defined as a listbox. The listbox item property contains a...
4
by: Moe Sizlak | last post by:
Hi There, I am trying to return the value of a listbox control that is included as a user control, I can return the name of the control but I can't access the integer value of the selected item,...
5
by: Drew | last post by:
I am building an application for inserting and updating one field in a database. The database is in SQL Server and I am using Classic ASP. I have a dropdown listbox that is populated with names,...
1
by: acord | last post by:
Hi, I am having problem to get a value of the selected item from a dropdown listbox. Here is the JS function; function getSelectedItem(objSelect) { alert("in getSelectedItem"); alert...
2
by: Greg | last post by:
I have a listbox inside of a DetailsView. There are three departments to choose from, Corporate, Group, Vacation. The listbox is set to SelectionMode="multiple". I think I have this loop setup...
4
by: igotyourdotnet | last post by:
I have a dropdown on my page and I want to define what should be selected in the drop down when the page loads. I have a session variable I'm setting to do this. I can get the selected value and...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.