Jump to content

getelementbyid and select menu problems


boggen

Recommended Posts

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

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
×
×
  • Create New...