boggen Posted November 13, 2006 Share Posted November 13, 2006 i thought i could access the select element by simply implying getelementbyid. but when i try i get...(( error:'document.getElementByID.b1' is null or not an object ))ay i can use (( forms["x"].elements["x"].what_i_want )) but boy do i not want to re type up a few pages to work in a forms name into the equations and variables. <html><head><script language="JavaScript" type="text/javascript">function clear_menu(){alert(document.getElementByID["b1"].selectedIndex);}function clear_menu2(){alert(document.forms["chap1"].elements["b1"].selectedIndex);}</script></head><body><form name="chap1"> <p> <input name="Button" type="button" onClick="clear_menu();" value="getelementbyid does not work"> (( error:'document.getElementByID.b1' is null or not an object )) </p> <p> <input name="Button" type="button" onClick="clear_menu2();" value="forms.elements works"> </p> <p> <select name="b1" id="b1"> <option value="123">456</option> <option value="234">567</option> <option value="345">678</option> </select> </p></form></body></html> Link to comment Share on other sites More sharing options...
skym Posted November 13, 2006 Share Posted November 13, 2006 try getElementById("b1") instead of getElementByID["b1"] Link to comment Share on other sites More sharing options...
boggen Posted November 13, 2006 Author Share Posted November 13, 2006 () {} [] no go. :/ thanks for trying. any other suggestions? Link to comment Share on other sites More sharing options...
aspnetguy Posted November 13, 2006 Share Posted November 13, 2006 it should be document.getElementById("b1") Link to comment Share on other sites More sharing options...
jesh Posted November 13, 2006 Share Posted November 13, 2006 Like the previous two posters said, it needs to be document.getElementById(). Your original code had "ID" rather than "Id". Watch out for that. Link to comment Share on other sites More sharing options...
boggen Posted November 13, 2006 Author Share Posted November 13, 2006 LOL *ughs* look at it so many times. it all looks the same to me. thank you all for pointing out the lower caseing. of ID to Id. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now