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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.