A
Andyza
I have a form with a number of textboxes. Each textbox has the same
name.
<input type="text" name="txtTest" value="1" onclick="GetValue()">
<input type="text" name="txtTest" value="2" onclick="GetValue()">
<input type="text" name="txtTest" value="3" onclick="GetValue()">
<input type="text" name="txtTest" value="4" onclick="GetValue()">
<input type="text" name="txtTest" value="5" onclick="GetValue()">
To loop through the textboxes and retrieve the value of each box I use
this loop:
<script language="javascript">
function GetValue() {
for (i=0; i<document.forms[0].txtTest.length; i++){
alert(document.forms[0].txtTest.value)
}
}
</script>
GetValue() gives me an array with the values of all the textboxes. How
do I get the function to return JUST the value of the textbox that I
clicked on?
Example, if I click on the third textbox it will display an alert with
3 and if I click on the first textbox it will display an alert with 1.
Thanks
name.
<input type="text" name="txtTest" value="1" onclick="GetValue()">
<input type="text" name="txtTest" value="2" onclick="GetValue()">
<input type="text" name="txtTest" value="3" onclick="GetValue()">
<input type="text" name="txtTest" value="4" onclick="GetValue()">
<input type="text" name="txtTest" value="5" onclick="GetValue()">
To loop through the textboxes and retrieve the value of each box I use
this loop:
<script language="javascript">
function GetValue() {
for (i=0; i<document.forms[0].txtTest.length; i++){
alert(document.forms[0].txtTest.value)
}
}
</script>
GetValue() gives me an array with the values of all the textboxes. How
do I get the function to return JUST the value of the textbox that I
clicked on?
Example, if I click on the third textbox it will display an alert with
3 and if I click on the first textbox it will display an alert with 1.
Thanks