473,766 Members | 2,159 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3322
"Eddy Scheire" <ed**********@s kynet.be> wrote in message
news:41******** *************@n ews.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="docum ent.getElementB yId('Desc').val ue=document.get ElementById('Pa r
t').value">
<option value="">
<option value="Product 1">123
<option value="Product 2">456
<option value="Product 3">789
</select>
<br><b>Produc t 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******** ************@co mcast.com...
"Eddy Scheire" <ed**********@s kynet.be> wrote in message
news:41******** *************@n ews.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="docum ent.getElementB yId('Desc').val ue=document.get ElementById('Pa r t').value">
<option value="">
<option value="Product 1">123
<option value="Product 2">456
<option value="Product 3">789
</select>
<br><b>Produc t 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.getEl ementById(str + 'Check').checke d)
{
document.getEle mentById(str + '1').style.disp lay = 'none';
document.getEle mentById(str + '2').style.disp lay = 'inline';
}
else
{
document.getEle mentById(str + '1').style.disp lay = 'inline';
document.getEle mentById(str + '2').style.disp lay = 'none';
}
}

<tr>
<td width="121" bgcolor="#E1E1E 1">ºÐ·ù</td>
<td colspan="3"><se lect 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="propartChec k" type="checkbox"
name="CheckEct" onClick="CheckE tc('propart');" checked>
±âŸ
</td>
</tr>

--
JinHyung Lee
msn : sa*****@hotmail .com
blog : http://ddongdog.egloos.com
"Eddy Scheire" <ed**********@s kynet.be> wrote in message
news:41******** *************@n ews.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.TARGETFIEL D.value=this[this.selectedIn dex].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="docum ent.getElementB yId('Desc').val ue=document.get ElementByID('Ba n
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******** ************@co mcast.com...
"Eddy Scheire" <ed**********@s kynet.be> wrote in message
news:41******** *************@n ews.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="docum ent.getElementB yId('Desc').val ue=document.get ElementById('Pa r t').value">
<option value="">
<option value="Product 1">123
<option value="Product 2">456
<option value="Product 3">789
</select>
<br><b>Produc t Description : </b>
<input type="text" name="Desc" id="Desc">
</body>
</html>

Jul 22 '05 #6
"Eddy Scheire" <ed**********@s kynet.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="docum ent.getElementB yId('Desc').val ue=document.get ElementByID('Ba n d').value">"


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

Response.Write "<select " _
& "align='cen ter' " _
& "name='Band ' " _
& "id='Band' " _
& "onchange=""doc ument.getElemen tById( 'Desc' ).value " _
& "= document.getEle mentByID( 'Band' ).value"" " _
& ">"

HTH,
Phill W.
Jul 22 '05 #7
"Eddy Scheire" <ed**********@s kynet.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="docum ent.getElementB yId('Desc').val ue=document.get ElementByID('Ba n 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='docum ent.getElementB yId('Desc').val ue=document.get ElementByID('Ba n
d').value'>"
Jul 22 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
5253
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 static values pre-programmed into the page and then set the listbox value to that of the one contained in the database for that particular record the code I'm using is - <select name="SelectGarage">
5
2068
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"> <option>Select Theme</option> <% Dim PassedTheme
16
11501
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 an object... the function is like so: function calc_total() { var x,i,base,margin,total,newmargin,newtotal; base = document.frmKitAmount.txtTotalKitValue.value; margin = document.frmKitAmount.margin.value/100;
2
6128
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 collection of status values. If I later pull an item record from the dataset into this item maintenance screen I cannot seem to get the status value that is contained in the dataset to display on the form, it displays the first value in the listbox...
4
2460
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, what do I need to do in order to return the "option value" of the control? Moe !--- returned value of the control
5
3258
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, when a name is selected it automatically submits the form and then replaces the dropdown listbox with the name of the resident selected. Now I need to take a field and split it into 2 textboxes. This is where my problems begin. The field is...
1
25732
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 (objSelect.length); alert (objSelect.value);
2
3811
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 correctly, the problem is as it is looping through it outputs the same value even though watching it validate each value - false, true, true - it repeats the value for the first "true" item it comes across. For instance if I choose Group and...
4
1628
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 selectedItem.Text from the user control dropdown, but how can I set what I want selected in the user control?
0
9404
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10168
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9959
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9838
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8835
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5279
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.