469,909 Members | 1,796 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,909 developers. It's quick & easy.

What am I overlooking? Totally stumped!

Expand|Select|Wrap|Line Numbers
  1. var s = document.getElementById('field[12]');
  2. var cust_cc_exp_month = s.options[s.selectedIndex].value;
  3.  
  4. // This displays the correct Value -- which is "0" for item #0 = "Please select..."
  5. alert("Month: " + cust_cc_exp_month.toString());
  6.  
  7. if (cust_cc_exp_month == "0") {
  8. // This code never executes!
  9. }
  10.  
  11. Here is the HTML portion:
  12.         <select id="field[12]" name="field[12]">
  13.         <option value="0">Select a Month...</option>
  14.         <option value="1" <?php if ($field[12] == "1") echo "SELECTED" ?>>January</option>
  15.         <option value="2" <?php if ($field[12] == "2") echo "SELECTED" ?>>February</option>
  16.         </select>
  17.  
I've tried using cust_cc_exp_month.toString(), and I've tried == 0 instead of == "0".
Nothing seems to work. To me, it defies all logic! There has to be something I'm overlooking.

Thanks for any help you can provide --

Matthew
Feb 28 '08 #1
2 815
hsriat
1,654 Expert 1GB
Try using id as field_12 instead of field[12] or give value="x" instead of 0.

Just a guess!
Feb 28 '08 #2
Markus
6,050 Expert 4TB
Try using id as field_12 instead of field[12] or give value="x" instead of 0.

Just a guess!
I believe id attributes can only be numbers, letters, underscores and hypens?
Feb 28 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

220 posts views Thread by Brandon J. Van Every | last post: by
54 posts views Thread by Brandon J. Van Every | last post: by
35 posts views Thread by wilsonidv | last post: by
reply views Thread by Sells, Fred | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.