Jump to content

Problem with getElementById


DickDeeds

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

Archived

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

×
×
  • Create New...