Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Box changes Text Box Value 2

Status
Not open for further replies.

CrazedWombat

Programmer
Jun 27, 2002
7
US
Basically, what I want to do is have a select box with different levels of membership. When a user chooses a level, a textbox is populated with a specified dollar amount.

Normally, I would just make the dollar amount the value of the OPTION, but there is also the option of choosing "other" and entering in any amount.
 
<select name=&quot;mLevel&quot; onchange=&quot;dollarAmt.value = this.options[this.selectedIndex].value&quot;>
<option value=&quot;&quot;>Choose:</option>
<option value=&quot;25&quot;>Bronze</option>
<option value=&quot;50&quot;>Silver</option>
<option value=&quot;100&quot;>Gold</option>
<option value=&quot;&quot;>Other</option>
</select>
<p />
<input type=&quot;text&quot; name=&quot;dollarAmt&quot; />
 
jemminger,
I tried that already, but the problem is, I need the value of the OPTION's to be somehting other than the dollar amount(i.e. the name of the level), so the dollar amounts have to come from somewhere else.

I guess I didn't explain myself well enough. Thanks so much for your help.
 
how about:
Code:
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 FINAL//EN&quot;>
<html>
<head>
<title></title>

<script name=&quot;javascript&quot;>
function putValue(sValue) {
	sValue = sValue.split(':');
	document.forms[0].dollarAmt.value = sValue[0];
	document.forms[0].otherText.value = sValue[1];
}
</script>

<style type=&quot;text/css&quot;>
</style>

<meta name=&quot;author&quot; content=&quot;?&quot;>
<meta name=&quot;keywords&quot; content=&quot;?&quot;>
<meta name=&quot;description&quot; content=&quot;?&quot;>
</head>

<body onload=&quot;&quot;>
<form>
<select name=&quot;mLevel&quot; onchange=&quot;putValue(this.options[this.selectedIndex].value);&quot;>
<option value=&quot;&quot;>Choose:</option>
<option value=&quot;25:otherBronze&quot;>Bronze</option>
<option value=&quot;50:otherSilver&quot;>Silver</option>
<option value=&quot;100:otherGold&quot;>Gold</option>
<option value=&quot;?:type your own&quot;>Other</option>
</select>
<p />
<input type=&quot;text&quot; name=&quot;dollarAmt&quot; />
<input type=&quot;text&quot; name=&quot;otherText&quot; />
</form>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top