What am I overlooking? Totally stumped!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CathInfo
    New Member
    • Feb 2008
    • 2

    What am I overlooking? Totally stumped!

    Code:
    var s = document.getElementById('field[12]');
    var cust_cc_exp_month = s.options[s.selectedIndex].value;
    
    // This displays the correct Value -- which is "0" for item #0 = "Please select..."
    alert("Month: " + cust_cc_exp_month.toString());
    
    if (cust_cc_exp_month == "0") {
    // This code never executes!
    }
    
    Here is the HTML portion:
    		<select id="field[12]" name="field[12]">
    		<option value="0">Select a Month...</option>
    		<option value="1" <?php if ($field[12] == "1") echo "SELECTED" ?>>January</option>
    		<option value="2" <?php if ($field[12] == "2") echo "SELECTED" ?>>February</option>
    		</select>
    I've tried using cust_cc_exp_mon th.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
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    Try using id as field_12 instead of field[12] or give value="x" instead of 0.

    Just a guess!

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      Originally posted by hsriat
      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?

      Comment

      Working...