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
 
Remeber the when you say:
<input name=&quot;MyArray&quot; type=&quot;hidden&quot; value=&quot;<%=MyArray%>&quot;>

You are saying
response.write myArray
Which is never a valid statement.

Try storing the array in a session variable.

Here's how... Get the Best Answers! faq333-2924
Merry Christmas!
mikewolf@tst-us.com
[angel][santa][elf][reindeer][santa2]
 
how about loop through the array and write each element to a hidden field.

might be a bit long winded though ---------------------------------------
{ 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

 
onpnt - It's not quite as elegant, but your method could free up some server memory....

<%
for x = 0 to uBound(myArray)
arrStr = &quot;##&quot; & myArray(x)
next
arrStr = mid(arrStr,3) 'trim off first delimiter
%>

<input name=&quot;MyArray&quot; type=&quot;hidden&quot; value=&quot;<%=arrStr%>&quot;>


on next page..

<%
arrStr = split(request(&quot;myArray&quot;),&quot;##&quot;)
%>
Get the Best Answers! faq333-2924
Merry Christmas!
mikewolf@tst-us.com
[angel][santa][elf][reindeer][santa2]
 
OOPPSS!!
<%
arrStr = &quot;&quot;
for x = 0 to uBound(myArray)
arrStr = arrStr & &quot;##&quot; & myArray(x)
next
arrStr = mid(arrStr,3) 'trim off first delimiter
%>

<input name=&quot;MyArray&quot; type=&quot;hidden&quot; value=&quot;<%=arrStr%>&quot;>


on next page..

<%
arrStr = split(request(&quot;myArray&quot;),&quot;##&quot;)
%>
Get the Best Answers! faq333-2924
Merry Christmas!
mikewolf@tst-us.com
[angel][santa][elf][reindeer][santa2]
 
How about using the join method? :)
Code:
<%
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:
Code:
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

Hop this helps, :)
-Tarwn


________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
Alas - once again - Tarwyn has improved my code.... Get the Best Answers! faq333-2924
Merry Christmas!
mikewolf@tst-us.com
[angel][santa][elf][reindeer][santa2]
 
doesn't that get irritating [curse]

I used to think I was good till I met Tarwn [sadeyes] ---------------------------------------
{ 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

 
Yeah, he's a right bastard

:) ________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
[rofl2] ---------------------------------------
{ 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

 
fart.gif
________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
opnpnt - you ARE good - it's just tarwyn...

{
str = &quot;onpnt - you ARE good&quot;;
alert(str);
ptr = /onpnt/gi;
Nstr = str.replace(ptr,&quot;Tarwyn&quot;);
ptr = /oo/gi;
Nstr = str.replace(ptr,&quot;o&quot;);
alert(Nstr);
}


I'm not good at regExps - but I think you'll get the picture... Get the Best Answers! faq333-2924
Merry Christmas!
mikewolf@tst-us.com
[angel][santa][elf][reindeer][santa2]
 
that's pretty good [thumsup2]

instead of a god can I be a king. ---------------------------------------
{ 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

 
Tarwyn - I think that is the BEST icon I have seen yet.... Get the Best Answers! faq333-2924
Merry Christmas!
mikewolf@tst-us.com
[angel][santa][elf][reindeer][santa2]
 
you mean you didn't lke mine [thumsup2] duhh [thumbsup2]

I think I'll stop before I get flagged for useless posts [wink] ---------------------------------------
{ 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

 
I'm still looking for a use for his one:
robot.gif


Although I've convinced myself to just look at this one at the appropriate times rathe than use it
banghead.gif

:)

Sorry for the hijack moroeh, got a little carried away
stickhorse.gif
________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
Don´t worry people.

But still have a problem (sorry about this ) I know your ego is gonna get hurt (or mine, if the problem results to be that I have no idea of making ASP's).

When I try to use the functions you say (join and split) I get the next error (I will try to translate because is not in english):

Response error 'ASP 0106 : 80020005'
Type Mismatch

I guess is because I have to redim the array (or the function itself is supposed to do it?) HELP, please!
 
what is going into the array and how are you populating it?

are you trying to write the array to the screen seeing as this is a response error? ---------------------------------------
{ 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

 
Actually, the array is supposed to be populated with dates. And I think I was trying to write it in the screen....

It works (I just made another trying)!!!

Thanks to all!

By the way, is there any webpage to know all this functions in VBscript (kind of glossary of functions)?

Thanks again!

Moroeh
 
there are a few alright reference downloads here
---------------------------------------
{ 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

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top