Placing the selection of a list field in a text field

J

Jerry Manner

Hi

I have a field with a list of items. Like below:
<select width="100" size="1" name="Industrielijst" style="font-family:
Arial; font-size: 8pt">
<option value="P1">Plants</option>
<option value="P2">Software</option>
<option value="P3">Hardware</option>
<option value="P4">System</option>
<option value="P5">Screens</option>
</select>

Above this field I have a text field, like this.
<input type="text" name="T1" size="40">

Is it possible when I make a selection to place that selection in the
text field automatically? If so , how can I do that with javascript?

Regards
 
H

Hywel Jenkins

Hi

I have a field with a list of items. Like below:
<select width="100" size="1" name="Industrielijst" style="font-family:
Arial; font-size: 8pt">
<option value="P1">Plants</option>
<option value="P2">Software</option>
<option value="P3">Hardware</option>
<option value="P4">System</option>
<option value="P5">Screens</option>
</select>

Above this field I have a text field, like this.
<input type="text" name="T1" size="40">

Is it possible when I make a selection to place that selection in the
text field automatically? If so , how can I do that with javascript?

Regards

Untested:
<select onchange="T1.value = this[this.selectedIndex].value;" ...
 
J

Jerry Manner

Hi

I did what you said, but the text field shows the text "undefined" when
I make a selection from the list. What must I change in the onchange
code?


Regards
 
J

Jerry Manner

Maybe I should mention this. The select part of the code is inside a
<div> tag.
 
M

Mark Parnell

Previously in alt.html said:
Hi
G'day.

I did what you said,

I didn't say anything.
but the text field shows the text "undefined" when
I make a selection from the list. What must I change in the onchange
code?

Impossible to say without a URL.
 
J

Jonathan N. Little

Hywel said:
Hi

I have a field with a list of items. Like below:
<select width="100" size="1" name="Industrielijst" style="font-family:
Arial; font-size: 8pt">
<option value="P1">Plants</option>
<option value="P2">Software</option>
<option value="P3">Hardware</option>
<option value="P4">System</option>
<option value="P5">Screens</option>
</select>

Above this field I have a text field, like this.
<input type="text" name="T1" size="40">

Is it possible when I make a selection to place that selection in the
text field automatically? If so , how can I do that with javascript?

Regards


Untested:
<select onchange="T1.value = this[this.selectedIndex].value;" ...
Couple things here..

1. Wrap the form elements in a form, else grabing T1 becomes very difficult
2. This DOES require Javascript to be ENABLED to work
3. The code:

<form>
<select width="100" size="1" name="Industrielijst" style="font-family:
Arial; font-size: 8pt"
onchange="this.form.T1.value=this.options[selectedIndex].value">
<option value="P1">Plants</option>
<option value="P2">Software</option>
<option value="P3">Hardware</option>
<option value="P4">System</option>
<option value="P5">Screens</option>
</select>
<input type="text" name="T1" size="40">
</form>
 

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,733
Messages
2,569,440
Members
44,832
Latest member
GlennSmall

Latest Threads

Top