By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,011 Members | 1,000 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,011 IT Pros & Developers. It's quick & easy.

Auto Populate Values

P: n/a
I have 4 possible values that I would like to populate a text box with
depending on which 4 values are sleected in a select box. Is there an
example out there for this?

Thanks
Frank

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
<script language="javascript">
function changetext(Dropdown_Val, Dropdown_Val_SI)
{
switch (Dropdown_Val[Dropdown_Val_SI].value)
{
case 'Cheese' :
document.MyForm.TextField.value="Cheese";
break
case 'Ham' :
document.MyForm.TextField.value="Ham";
break
default :
document.MyForm.TextField.value="No Value";
break
}
}
</script>

<form name="MyForm">
<select name="DropField" onChange="changetext(this,this.selectedIndex);">
<option value="Choose">Choose</option>
<option value="Ham">Ham</option>
<option value="Cheese">Cheese</option>
</select>
<input type="text" name="TextField">
</form>

Stu

"Frank Py" <fp*@proactnet.com> wrote in message
news:3e*********************@news.frii.net...
I have 4 possible values that I would like to populate a text box with
depending on which 4 values are sleected in a select box. Is there an
example out there for this?

Thanks
Frank

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Jul 20 '05 #2

P: n/a
"Stuart Palmer" <tr**********@youcant.com> wrote in message news:<hN****************@newsfep2-gui.server.ntli.net>...
<script language="javascript">
function changetext(Dropdown_Val, Dropdown_Val_SI)
{
switch (Dropdown_Val[Dropdown_Val_SI].value)
{
case 'Cheese' :
document.MyForm.TextField.value="Cheese";
break
case 'Ham' :
document.MyForm.TextField.value="Ham";
break
default :
document.MyForm.TextField.value="No Value";
break
}
}
</script>

<form name="MyForm">
<select name="DropField" onChange="changetext(this,this.selectedIndex);">
<option value="Choose">Choose</option>
<option value="Ham">Ham</option>
<option value="Cheese">Cheese</option>
</select>
<input type="text" name="TextField">
</form>

Stu

"Frank Py" <fp*@proactnet.com> wrote in message
news:3e*********************@news.frii.net...
I have 4 possible values that I would like to populate a text box with
depending on which 4 values are sleected in a select box. Is there an
example out there for this?

Thanks
Frank

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


<form name="MyForm">
<select name="DropField" onChange="document.MyForm.TextField.value =
this.options[this.selectedIndex].value;">
<option value="">Choose</option>
<option value="Ham">Ham</option>
<option value="Cheese">Cheese</option>
</select>
<input type="text" name="TextField">
</form>
Jul 20 '05 #3

P: n/a
JHLeong wrote on 30 jun 2003 in comp.lang.javascript:
<form name="MyForm">
<select name="DropField" onChange="document.MyForm.TextField.value =
this.options[this.selectedIndex].value;">
<option value="">Choose</option>
<option value="Ham">Ham</option>
<option value="Cheese">Cheese</option>
</select>
<input type="text" name="TextField">
</form>


Nice and short, I changed it to:

<select
onChange="location.href =
this.options[this.selectedIndex].value;">
<option value="">Go to</option>
<option value="http://cnn.com/">CNN</option>
<option value="http://google.com/">Google</option>
</select>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #4

P: n/a
Frank Py wrote on 30 jun 2003 in comp.lang.javascript:
Thanks for the great examples. I just have one more question on this.
I'm using some sample code that uses ASP and the Response.Write to write
out all the html as it is called with functions. So when it hits the
first double quote in these examples, it thinks it the end of a state
ment:

Response.Write "<tr><td>Date</td>"


Use single quotes in javascript.

====================================

or change

Response.Write "<option value='http://google.com/'>Google</option>"

to

%><option value="http://google.com/">Google</option><%

because why use Response.Write in stead of straight html here ????

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.