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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passina value from a drop down list

Status
Not open for further replies.

stan8450

Programmer
May 3, 2002
16
CA
I would like to pass a value from a drop down list to a text box after a cmd button is pressed.

Here is what I have so far:

function Calculate()
{
if(document.orderform.Inspection_Type.selectedIndex == 3)
{
document.orderform.Approximate_Fee.value=="295";
}


thanks
 
You were close. Do this instead:

function Calculate(){
if(document.orderform.Inspection_Type.options[document.orderform.Inspection_Type.selectedIndex] == 3){
document.orderform.Approximate_Fee.value="295";
}
}

Rick

BTW.
It might be easier to do this:
<select onChange=&quot;Calculate(this)&quot;>
<option value=&quot;none&quot;>--Select an option--</option>
<option value=&quot;295&quot;>This is an option!</option>
.....

function Calculate(that)
{
if(that.options[that.selectedIndex].value!=&quot;none&quot;){
document.orderform.Approximate_Fee.value=
that.options[that.selectedIndex].value;
}
}

This way you won't have to type out the long string for each option. if(($question==&quot;has been bugging me&quot;
AND $answer==&quot;fixed the problem&quot;) OR $answer==&quot;really good post&quot;){
print(&quot;Star&quot;);
}else{
print(&quot;Thanks.&quot;);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top