Javascript drop down menu calculation
- by Janis Yee
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 />