Jump to content

Javascript and select boxes


eva21

Recommended Posts

Here is my html code:

<select name="courseMaintance" id="courseMaintance">

<option value="0"></option>

<option value="0.05">5%</option>

<option value="0.10">10%</option>

<option value="0.15">15%</option>

<option value="0.20">20%</option>

<option value="0.25">25%</option>

<option value="0.30">30%</option>

<option value="0.50">50%</option>

</select>

 

Here is my javascript:

  var x = document.courseMaintance.selectedIndex;

  var selected_percent = document.courseMaintance.option[x].text;

 

and it keeps saying its a null object...what am i doing wrong?

Link to comment
https://forums.phpfreaks.com/topic/135398-javascript-and-select-boxes/
Share on other sites

I don't know if this will help you but i just did up a select option and to access the value that was selected i usedsomething sililar like:

var selected_percent = document.getElementById('courseMaintance).value

that way i access the value directly, i don't know if it's needed or not, but it works.

 

later days,

gathos

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.