Is it possible to retrieve the index of an html element (ie Input button) that is in an array?
For example:
Kate
[small]"Forever dork"[/small]
For example:
Code:
<html>
<input type="button" id="theButton" value="Button One" onclick="theButton_onclick();"/>
<br><br>
<input type="button" id="theButton" value="Button Two" onclick="theButton_onclick();"/>
<br><br>
<span>You pressed: </span><span id="testResult"></span>
</html>
<script language="javascript">
function theButton_onclick(){
var buttonPushedID = event.srcElement.id;
testResult.innerText = buttonPushedID;
/*
I want to preserve the identifier for which button was pushed.
However, I only want to preserve the value as text, not as an object.
For example, I would use something like:
eval('document.all.' + buttonPushedID);
If I do that, however, without referencing the index, I would obviously get an error.
So is there a way to preserve the array index of the button? I would love it if I could do:
var buttonPushedIDArray = event.srcElement.id + "(" + event.srcElement.index + ")";
But alas, there is no index attribute.
*/
}
</script>
Kate
[small]"Forever dork"[/small]