Click to See Complete Forum and Search --> : [RESOLVED] textbox array in form : how access it in vbscript ?
Teranoz
June 8th, 2009, 10:05 AM
<form name="Boeking">
<input type="text" name="jsarSubBedrag">
<input type="text" name="jsarSubBedrag">
<input type="text" name="jsarSubBedrag">
<input type="text" name="jsarSubBedrag">
<input type="text" name="jsarSubBedrag">
</form>
I can access all those in javascript with
var total = 0;
for(x=0;x<5;x++)
{
total = total + document.forms["Boeking"].jsarSubBedrag[x].value;
}
But how should I do this in vbscript ?
PeejAvery
June 10th, 2009, 12:29 PM
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_23175586.html
Teranoz
June 12th, 2009, 07:37 AM
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_23175586.html
Thats serverside vbscript, I need it in clientside vbscript.
PeejAvery
June 12th, 2009, 09:39 AM
Still, the principal is the same thing. VBScript, whether client-side or server-side, retains its syntax.
<form name="testForm">
<input type="text" name="testInput" value="1">
<input type="text" name="testInput" value="2">
<input type="text" name="testInput" value="3">
<input type="text" name="testInput" value="4">
<input type="text" name="testInput" value="5">
</form>
<script type="text/vbscript">
For Each inp in testForm.testInput
inp.Value = "Testing"
Next
</script>
Teranoz
June 15th, 2009, 03:33 AM
kk, so with a "for each" you can access them all.
But how do I know its the third one for example ?
Is this possible ?
<form name="testForm">
<input type="text" name="testInput" value="1">
<input type="text" name="testInput" value="2">
<input type="text" name="testInput" value="3">
<input type="text" name="testInput" value="4">
<input type="text" name="testInput" value="5">
</form>
<script type="text/vbscript">
Dim Counter
Counter = 0
For Each inp in testForm.testInput
counter = counter + 1
if counter = 3 then
inp.Value = "Testing"
exit for
end if
Next
</script>
PeejAvery
June 15th, 2009, 08:11 AM
That's one way. Or, you can use a For incrementing loop. Take your pick.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.