View Full Version : Dropdown Box: Value Change Confirmation

05-18-2009, 07:31 PM
Hi there, I am having a little problem trying to set this code up so that when I click on the drop down box, and select the 5th value down it should spit out text saying "Good Morning", and if it is anything else but value 5, "Bad Day".

It seems it never spits out "Bad Day", and that is not making my day very good at all lol. So if anyone could help me correct this problem it would be greatly appreciated.

var oQty=f['qty'+i];

if (oQty = 5)
document.write("Good morning!");
document.write("Bad day!");

<form action="" name="form" id="form">
<div><span id="spryselect1">
<select name="qty" id="qty">
<option value="1">1 - $24.95</option>
<option value="2">2 - $24.95</option>
<option value="3">3 - $22.95</option>
<option value="4">4 - $20.95</option>
<option value="5">5 - $19.95</option>
<option value="6">6 - $18.95</option>
<option value="7">7 - $17.95</option>
<option value="8">8 - $16.95</option>
<option value="9">9 - $15.95</option>


05-18-2009, 08:20 PM
Usually... when an if statement isn't working, look at what you're checking against:

if (oQty = 5)

The code up there says... "If assigning 5 to oQty is a success, do whatever". What you need instead:

if (oQty == 5)

See how that goes for you.