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

+ value of 2 combo boxes

Status
Not open for further replies.

sdi

Technical User
Jun 25, 2003
65
US
Any help would be greatly appreciated. I am attempting to add the value from the selections in combo boxes and return the results back as the "amount" on the page being viewed. I apologize in advance for being very new to this.

<body>

<select size=&quot;1&quot; name=&quot;Prod1_Select&quot;>
<option selected value=&quot;100.00&quot;>One</option>
<option value=&quot;150.00&quot;>Two</option>
<option value=&quot;175.00&quot;>Three</option>
</select>

<select size=&quot;1&quot; name=&quot;Prod2_Select&quot;>
<option selected value=&quot;100.00&quot;>One</option>
<option value=&quot;150.00&quot;>Two</option>
<option value=&quot;175.00&quot;>Three</option>
</select>

<Script Language=&quot;JavaScript&quot;>
var amount=Prod1_Select.value + Prod2_Select.value;
return(amount);
</Script>

As you can see I am very lost... what's more is that once this is fixed then I want it to update the amount anytime one of the option values are changed... onChange??? and have no clue how to do it either

Thank you in advance

Brian
 
Actually Greelmo,
It's document.formName.SelectName[document.formName.SelectName.selectedIndex].value

Adam
while(woman.width>woman.height && wallet.value>0){beer++;vision.blur()};
 
Thanks.. I found an article in the F&Q that helped me out and I have them calculating the values. I have default values selected but have to run them with a &quot;onclick&quot; in the form tags. Then I have a &quot;onchange&quot; in the select tags. It works as is however, rather than have the &quot;onclick&quot; I would rather have it display the defaults when the form opens up. If I replace the &quot;onclick&quot; with &quot;onload&quot; it does nothing for me... anyone have a suggestion?

Brian
 
This is what I have for my script..

function updateval()
{
if(document.microMite.Memory_Select.options[0].value == true) {
return false
}
else
document.microMite.textfield.value=document.microMite.Memory_Select.options[document.microMite.Memory_Select.selectedIndex].value;
document.microMite.textfield1.value=document.microMite.Cpu_Select.options[document.microMite.Cpu_Select.selectedIndex].value;
document.microMite.amount.value=parseFloat(document.microMite.Memory_Select.options[document.microMite.Memory_Select.selectedIndex].value) +
parseFloat(document.microMite.Cpu_Select.options[document.microMite.Cpu_Select.selectedIndex].value);

return true;
}
//-->
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top