eva21 Posted December 3, 2008 Share Posted December 3, 2008 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? Quote Link to comment Share on other sites More sharing options...
jwilliam Posted December 3, 2008 Share Posted December 3, 2008 That's because courseMaintance is not a direct child of document. The easiest way to access the select (but not the most efficient... fyi) is to do something like this: var select_menu = document.getElementById('courseMaintance'); Quote Link to comment Share on other sites More sharing options...
gathos Posted December 3, 2008 Share Posted December 3, 2008 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.