Jump to content

Html Dom Issue With <select> Tag


toreachdeepak

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

Archived

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

×
×
  • Create New...