Jump to content

Problem with getElementById


DickDeeds
 Share

Recommended Posts

I have a problem accessings information in a accounting program. I have to know what type of account in order to insure accurate entries. The type is shown by the value in the fields below. The number of fields will depend on the client.<input type="hidden" name="hid0" id="hid0" value="L"><input type="hidden" name="hid1" id="hid1" value="A"><input type="hidden" name="hid2" id="hid2" value="R"><input type="hidden" name="hid3" id="hid3" value="E"><input type="hidden" name="hid4" id="hid4" value="R"><input type="hidden" name="hid5" id="hid5" value="A">..... on to end, end found from database.I’ve been using this code in the java script:$what="hid0";var tt=getElementById("hid0").value;alert("tt="+tt);But the alert NEVER shows up. I have to use the $what because the number of hiddens is unknown so I have to build the call in code like:Var tt=getElementById($what).valueNeither works.Can anyone help?###### Deeds

Link to comment
Share on other sites

Try adding it in a function and call the function when the page loads.

function check() {what="hid0";var tt=document.getElementById("hid0").value;return alert("tt="+tt);}

And use an onload event handler

<body onload="return check()";>

The value is null before the page loads. Therefore, you have to call it after the page is finished loading.

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...