Populating text box from drop down

T

Trillian

I found the following tip (below) on a post of a few days
ago - it's what I want to do - take the value selected
from a dropdown and place it in a text box to query the db.

But when I run the .asp page the value placed in my text
box is [object] - not the value I selected in the
dropdown. What am I doing incorrectly?

Here's the post suggestion and code; my dropdown has one
column of data from a db.

"Use the onchange event of the drop down to populate the
text box:"

<select onchange="if (this.selectedIndex > 0) {
this.form.my_text_field.value = this.options
[this.selectedIndex]; }" >
 
M

MD WebsUnlimited.com

Hi Trillian,

It is early and I've not had my coffee yet, but why would you not just use
the dropdown value, i.e., why does the value have to be moved to a text box?

The code is:
select onchange="if (this.selectedIndex > 0) { this.form.my_text_field.value
= this.options [this.selectedIndex].value; }"
 
T

Trillian

Thanks for the assistance...

The text box can also be used to query the db.

My idea is to let users look up a value from the dropdown
or key in whatever they want to look up. When they click
the dropdown value I want it to move over to the text box
and query the db...sounds simple in theory!
-----Original Message-----
Hi Trillian,

It is early and I've not had my coffee yet, but why would you not just use
the dropdown value, i.e., why does the value have to be moved to a text box?

The code is:
select onchange="if (this.selectedIndex > 0) { this.form.my_text_field.value
= this.options [this.selectedIndex].value; }"


Trillian said:
I found the following tip (below) on a post of a few days
ago - it's what I want to do - take the value selected
from a dropdown and place it in a text box to query the db.

But when I run the .asp page the value placed in my text
box is [object] - not the value I selected in the
dropdown. What am I doing incorrectly?

Here's the post suggestion and code; my dropdown has one
column of data from a db.

"Use the onchange event of the drop down to populate the
text box:"

<select onchange="if (this.selectedIndex > 0) {
this.form.my_text_field.value = this.options
[this.selectedIndex]; }" >


.
 
K

Kathleen Anderson [MVP- FP]

Trillian:
If you generate the values in the dropdown from the database, there won't be a need for the users to key anything in, because the dropdown will give them all the possible valid values.

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q235554&GSSNB=1


--

~ Kathleen Anderson
Microsoft FrontPage MVP
Spider Web Woman Designs
http://www.spiderwebwoman.com/resources/



Thanks for the assistance...

The text box can also be used to query the db.

My idea is to let users look up a value from the dropdown
or key in whatever they want to look up. When they click
the dropdown value I want it to move over to the text box
and query the db...sounds simple in theory!
-----Original Message-----
Hi Trillian,

It is early and I've not had my coffee yet, but why would you not
just use the dropdown value, i.e., why does the value have to be
moved to a text box?

The code is:
select onchange="if (this.selectedIndex > 0) {
this.form.my_text_field.value = this.options
[this.selectedIndex].value; }"


Trillian said:
I found the following tip (below) on a post of a few days
ago - it's what I want to do - take the value selected
from a dropdown and place it in a text box to query the db.

But when I run the .asp page the value placed in my text
box is [object] - not the value I selected in the
dropdown. What am I doing incorrectly?

Here's the post suggestion and code; my dropdown has one
column of data from a db.

"Use the onchange event of the drop down to populate the
text box:"

<select onchange="if (this.selectedIndex > 0) {
this.form.my_text_field.value = this.options
[this.selectedIndex]; }" >


.
 
M

MD WebsUnlimited.com

If all possible values are in the drop down then there is no need for the
text box. As Kathleen keeps saying you can generate the dropdown from the DB
if you wish.
--
Mike -- FrontPage MVP '97-'02
http://www.websunlimited.com
FrontPage Add-ins Since '97 2003 / 2002 / 2000 Compatible
----------------------------------------------------------------------------
--------------------
If you think I'm doing a good job, let MS know at (e-mail address removed)

Trillian said:
Thanks for the assistance...

The text box can also be used to query the db.

My idea is to let users look up a value from the dropdown
or key in whatever they want to look up. When they click
the dropdown value I want it to move over to the text box
and query the db...sounds simple in theory!
-----Original Message-----
Hi Trillian,

It is early and I've not had my coffee yet, but why would you not just use
the dropdown value, i.e., why does the value have to be moved to a text box?

The code is:
select onchange="if (this.selectedIndex > 0) { this.form.my_text_field.value
= this.options [this.selectedIndex].value; }"


Trillian said:
I found the following tip (below) on a post of a few days
ago - it's what I want to do - take the value selected
from a dropdown and place it in a text box to query the db.

But when I run the .asp page the value placed in my text
box is [object] - not the value I selected in the
dropdown. What am I doing incorrectly?

Here's the post suggestion and code; my dropdown has one
column of data from a db.

"Use the onchange event of the drop down to populate the
text box:"

<select onchange="if (this.selectedIndex > 0) {
this.form.my_text_field.value = this.options
[this.selectedIndex]; }" >


.
 

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

Top