toreachdeepak Posted April 2, 2009 Share Posted April 2, 2009 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 More sharing options...
Ingolme Posted April 2, 2009 Share Posted April 2, 2009 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 More sharing options...
toreachdeepak Posted April 3, 2009 Author Share Posted April 3, 2009 Hi,Thanks for your reply. But I am using author as the id.RegardsDeepak Bhatia Link to comment Share on other sites More sharing options...
jesh Posted April 3, 2009 Share Posted April 3, 2009 Are you executing the javascript before the browser has a chance to build the select element? Link to comment Share on other sites More sharing options...
toreachdeepak Posted April 4, 2009 Author Share Posted April 4, 2009 Are you executing the javascript before the browser has a chance to build the select element?ThanksI am doing onClick on input type "submit". Since I am doing form submission through the Ajax which doesn't allow onSubmit event.ThanksDeepak Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.