Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

send array with method post 3

Status
Not open for further replies.

moroeh

Programmer
Oct 22, 2001
25
0
0
ES
Hi:

I guess somebody already answered this, but I am not able to find any answer. Does anybody know how to send an array in VBScript with the post method?

I have been trying to send it with

<input name=&quot;MyArray&quot; type=&quot;hidden&quot; value=&quot;<%=MyArray%>&quot;>
<input name=&quot;x&quot; type=&quot;submit&quot; value=&quot;Next&quot; />

When I send this and I try to use it in the page I am calling to I get a Type Mismatch error. How could I solve it?

Thanks in advance!!!!

Moro
 
I can't think of one offhand that is good. There are a couple out there that almost work right, that have listings:

-Tarwn ________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
that's funny, I came back to post that link [smile]

from the link I posted earlier windows script 5.6 is pretty good. I use it often ---------------------------------------
{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }
---------------------------------------
for the best results to your questions: FAQ333-2924

 
The problem with my link above is that it includes a section called VBA methods not in VBScript, and then ioncludes those functions in the drop down selection without specifrying that they won't work in VBScript, for example the MsgBox function is listed...

________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
Ah, but MsgBox does work in client-side VBScript(and it's much nicer than alert())..... Get the Best Answers! faq333-2924
Merry Christmas!
mikewolf@tst-us.com
[angel][santa][elf][reindeer][santa2]
 
Ok, true, perhaps I just think they should have specified client-side vs Server-side vs VBA only, vs windows scripting.

:p

I'm just peculiar like that

-Tarwn ________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
ahhh...very peculiar indeed he is

I agree that if the msgbox was not included on many of these references and or have server/client references seperated in ALL cases then that great question we get so often of why my msgbox doesn't work here in the great and only ASP forum would be brought to a minimum. :p ---------------------------------------
{ str = &quot;sleep is good for you. sleep gives you the energy you need to function&quot;;
ptr = /sleep/gi;Nstr = str.replace(ptr,&quot;coffee&quot;);alert(Nstr); }
---------------------------------------
for the best results to your questions: FAQ333-2924

 
inglés por favor?
l'anglais se vous plais?
inglese per favore?
inglês por favor?
Englisch bitte?

And thats where my google skills run out. :)
-Tarwn ________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
You guys have entirely TOO much time on your hands. Great icons!

The original problem is one that I think onpnt responded to best: &quot;how about loop through the array and write each element to a hidden field&quot;.
He just didn't provide any details.

In HTML, when you name several text input fields the same, they ALL get included what gets sent to the subject of the <form action=...>.

In ASP's request object, this situation results in the field being presented as a comma-sperated string.

e.g.

someform.html
<form action=&quot;someprocessor.asp&quot;>
<input type=&quot;text&quot; name=&quot;same&quot; value=&quot;a&quot;><br>
<input type=&quot;text&quot; name=&quot;same&quot; value=&quot;b&quot;><br>
<input type=&quot;text&quot; name=&quot;same&quot; value=&quot;c&quot;><br>
<input type=submit value=&quot;Do it!&quot;>

If you started with an array, generating the input fields can be accomplished with (someform.html becomes someform.asp):
<%
for i = 0 to Ubound(myArray)
s = &quot;<input type='text' name='same' value='&quot; &
myArray(i) & &quot;'><br>&quot; & vbcrlf
next
%>

someprocessor.asp
<%
s = request.form(&quot;same&quot;)
response.write &quot;s=&quot; & s
%>
will show &quot;a,b,c&quot;
if you wanted to reconstruct this into an array, it's really easy:
<%
dim aSame
aSame = array(request.form(&quot;same&quot;))
%>

Hope this help (sorry, no nifty icons).
 
How about using the join method? :)
<%
Dim arrString
arrString = Join(myArray,&quot;##&quot;)
%>
<input type=&quot;hidden&quot; name=&quot;hdnArray&quot; value=&quot;<%=arrString%>&quot;>

Then on the next page just use the split method to break it back into an array:

Dim myArray
myArray = Split(Request.Form(&quot;hdnArray&quot;),&quot;##&quot;)


You can specify any delimiter you would like in the Join and it will basically loop through the array for you, concatenating each element to the next with the chosen delimiter
________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
Star for Tarwn

My function choice was incorrect:

aSame = array(request.form(&quot;same&quot;))
...should have been ...
aSame = split(request.form(&quot;same&quot;), &quot;,&quot;)

array() built-in function takes n args, each of which are strings.

split() built-in function takes a single parm (a some-character delimited string), and an optional 2nd parm to specify what the delimiter is. Default delimiter is space character.

In both cases you want to declare the target variable (if using option explicit), but NOT define it as an array. Both split and array function handle that just fine.

i.e. dim myArray versus dim myArray()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top