Reputation: 19
Following code produces JavaScript error: Uncaught TypeError: undefined is not a function: orderquantity onchange
From what I can tell, this script should work. I have googled this issue quite a bit and ALL the sugestions involve renaming things so they don't conflict, but I have made sure that I don't have a conflicting element name or ID.
This may be a typographical issue, but I can't find the issue. Please help.
<script type="text/javascript">
function orderquantity(myvalue)
{
if (myvalue == "Custom") {
document.getElementByID('cquant').style.display="inline-block";
}else{
document.getElementByID('cquant').style.display="none";
document.getElementByID('customquant').value="";
}
}
</script>
<select name="quantity" id="quant" onchange="orderquantity(this.selectedIndex);">
<option value="MatchLast" selected="selected">Same as Last Time</option>
<option value="500">500</option>
<option value="1000">1000</option>
<option value="2500">2500</option>
<option value="5000">5000</option>
<option value="10000">10000</option>
<option value="Custom">Custom Quantity</option>
</select>
<div id="cquant" style="display: none;">
<input type="text" name="CustomAmount" id="customquant">
</div>
Upvotes: 0
Views: 1843
Reputation: 52
Agreed, It is more than likely a problem with you getElementByID. What you are looking for is getElementById.
Also as Nolutysses has said, you should you this.value. But you can also stay with what you have except add .innerHTML. So it would be this.selectedIndex.innerHTML. But this.value is shorter and easier to understand
Upvotes: 0