PDA

View Full Version : I have a form with a drop down selector how do I?


jasear
11-07-2005, 02:58 PM
Ok there is a selector in a form and once someone selects a number from it I want to populate another text field with a something else.

So for example the drop down selector has options like:

087353737663
038376338837
373838398393

As soon as the user selects 087353737663, I want to display something in a text box right next to it.

How do i do this?

thanks

jasear
11-07-2005, 03:38 PM
pls! Someone help!

Nischumacher
11-07-2005, 04:05 PM
<html>
<body>
<select name="numSelect" onchange="textbox1.value=numSelect.value;">
<option>Select a Number</option>
<option value="aaa">111</option>
<option value="bbb">222</option>
<option value="ccc">333</option>
</select>
<input type="text" name="textbox1">
</body>
</head>


just give the value you want to pass to the textbox to that particular option...
if you want to pass aaa when user selects number 111... then...
<option value="aaa">111</option>

jasear
11-07-2005, 04:31 PM
ok thanks a lot that helped but i think i should explain a bit more what i am trying to do.

The selector is something like this:

<html>
<body>
<select name="numSelect" onchange="textbox1.value=numSelect.value;">
<option>Select a Number</option>
<option value="1">0845345123</option>
<option value="2">0845345222</option>
<option value="3">0845345333</option>
</select>
<input type="text" name="textbox1" >
</body>
</head>

Now what i want is to lookup up in a table and first of all find a certain value from a field. This field is between 3 and 7. Depending on what it is i want to trim the number in the selector and display it in the text box.

So lets say the user selects: 0845345123 and the value i am getting from the database is 4 then I want in the text box to display the last four digits of the selected number (0845345123) which would be 5123.

I cannot change the value field in the selector to match 5123 for example as this has other implications. I am using asp.

kampfer
11-08-2005, 04:19 AM
is this what you are looking for?
<select name="numSelect" onchange=" RetrieveNumber( textbox1, numSelect )">
<option>Select a Number</option>
<option value="0845345123">0845345123</option>
<option value="0845345222">0845345222</option>
<option value="0845345333">0845345333</option>
</select>
<input type="text" name="textbox1">


function RetrieveNumber( textbox, numSelect )
{
var extract = numSelect.value;
var start = 6;
var end = 10;
var hold;
hold = extract.substring( start, end );

textbox.value = hold;
}

-john