Javascript drop down menu calculation
Posted
by
Janis Yee
on Stack Overflow
See other posts from Stack Overflow
or by Janis Yee
Published on 2012-10-03T02:32:13Z
Indexed on
2012/10/03
3:37 UTC
Read the original article
Hit count: 135
JavaScript
|options
I'm having a bit of an issue with me code. I'm trying to do a calculation from a drop down menu and then it will onChange to a textbox. I've been at it for days trying to figure it out and Googling ways to code the function. Can anyone please help or give me advice on how to approach this?
function numGuest()
{
var a = document.getElementById("guests");
if(a.options[a.selectedIndex].value == "0")
{
registration.banq.value = "0";
}
else if(a.options[a.selectedIndex].value == "1")
{
registration.banq.value = "30";
}
}
<select id="guests" name="guests">
<option value="0">0</option>
<option value="1">1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<input type="text" id="banq" name="banq" onChange="numGuest()" disabled />
© Stack Overflow or respective owner