|
-
Dec 22nd, 2005, 01:42 PM
#1
Thread Starter
Addicted Member
Control array in VBScript
Hail,
If I have 3 text boxes with the same name that I put in an array:
<input name='txtInput[]' size='5'>
<input name='txtInput[]' size='5'>
<input name='txtInput[]' size='5'>
How can I in a vbscript refer to #2 for example? I thought I could say something like:
<SCRIPT LANGUAGE="VBScript">
<!--
Sub B1_OnClick
msgbox txtInput(2).value
End Sub
-->
</SCRIPT>
But it doesn't work, this might be fairly obvious, can someone help me out?
-
Dec 22nd, 2005, 03:05 PM
#2
Re: Control array in VBScript
That code could work in VB6.
Here, though, all elements must have a different name/id, and so you cannot have any control array in your html pages. What are you trying to accomplish that requires a control array?
-
Dec 22nd, 2005, 03:33 PM
#3
Thread Starter
Addicted Member
Re: Control array in VBScript
 Originally Posted by mendhak
That code could work in VB6.
Here, though, all elements must have a different name/id, and so you cannot have any control array in your html pages. What are you trying to accomplish that requires a control array?
Basically, I want to display three fields from a database that match a certain criteria. So let's say I have name, email and phone in my DB and I want to display that in text boxes for records added in the past week. Using PHP, I retrieve the info and create a simple HTML form and basically show the three fields for each record. Then info can be changed and submitted, and I found in PHP that to do so I have to put the [] with the control name to create an array, which works fine. But now let's say I want to put some validation on those text boxes, I can't? If it works for HTML and PHP, why won't it cooperate with VBscript?
-
Dec 23rd, 2005, 07:19 PM
#4
Re: Control array in VBScript
With ASP, in your loop, you can generate your INPUT elements like so:
<input id=MyTextBox<% =i %>
where i is an incremented variable in your loop. You would then access the values/perform validation similarly, by concatention.
Although the square brackets seem valid enough as a value for name in the input element, I do not know how one would implement the same thing in ASP.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|