Jump to content

Html Dom Issue With <select> Tag


toreachdeepak
 Share

Recommended Posts

Hi,I have following code in my PHP Page<select id="author" name="test[]"><option value=""><?php echo " "?></option><?php foreach($listofemployees as $ls): ?><option value="<?php echo $ls->getEmpId();?>"><?php echo $ls->getEmpTable()->getName(); ?></option><?php endforeach; ?></select>In my javascript function, I have following codevar x = document.getElementById("sample").selectedIndex;But I get selectedIndex as Undefined.Please help me in this regard.ThanksDeepak Bhatia

Link to comment
Share on other sites

The ID of your <select> element is "author", yet you're using "sample" in the Javascript code. Try this:

var x = document.getElementById("author").selectedIndex;

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...