• Your answer is below... – Jacques ジャック Aug 01 '13 at 14:51
  • 1 Answers1

    -1

    You need the set a value for each option:

    <select id="selected2">
          <option selected value=""></option>
          <option value="2">2</option>
          <option value="3">3</option>
      </select>
    

    The text between the tags is just for the user to see, but does not return the value.

    Also, your javascript variable should read:

    var dataCap = document.getElementById("selected2").value;
    

    I added .value to the end so it knows to get the value.

    Jacques ジャック
    • 3,420
    • 2
    • 16
    • 40
    • http://jsfiddle.net/M9YrV/ Yes you need an onchange event trigger on the select field with a defined function to do what you need. – Jacques ジャック Aug 01 '13 at 15:06
    • However, if I use `onchange` that requires the use of a corresponding function. If I use a function to capture data from the ` – user2642359 Aug 01 '13 at 15:20
    • This answer results in "TypeError: document.getElementById(...) is Null" – user2642359 Aug 01 '13 at 15:21
    • If you view the jsfiddle i posted, when you make the selection, it shows the selection below. I'm not sure how that = null. – Jacques ジャック Aug 01 '13 at 15:27