Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asptoday_discuss thread: Passing Arrays from JS file to ASP


Message #1 by "Ketan G. Deshpande(ISRC)" <kgd@i...> on Fri, 2 Nov 2001 11:06:06 +0530
Hi,



Is it possible to pass array from client side Javascript file (.js) to asp ?

I'm using XMLHTTPRequest object to call the ASP but I could not get the

Array passed in my ASP code neither through REquest .Querystring nor using

REquest object directly.

Please let me know if there is way out.





Regards,

Ketan Deshpande

Information Systems Resource Center Ltd.

Tel  :(91-20)5411581/82 

Fax :(91-20)5411585

(For SMS Problems/Communication please CC mails to SMS Help Desk (ISRC) -

smshd@i...)

VISIT US at:- www.isrcsoft.com



Message #2 by "Nicholas Murray" <murray_nicholas@h...> on Tue, 6 Nov 2001 11:31:13
> Hi,

> 

> Is it possible to pass array from client side Javascript file (.js) to 

asp ?

> I'm using XMLHTTPRequest object to call the ASP but I could not get the

> Array passed in my ASP code neither through REquest .Querystring nor 

using

> REquest object directly.

> Please let me know if there is way out.

> 

> 

> Regards,

> Ketan Deshpande

> Information Systems Resource Center Ltd.

> Tel  :(91-20)5411581/82 

> Fax :(91-20)5411585

> (For SMS Problems/Communication please CC mails to SMS Help Desk (ISRC) -

> smshd@i...)

> VISIT US at:- www.isrcsoft.com

> 

Message #3 by "Nicholas Murray" <murray_nicholas@h...> on Tue, 6 Nov 2001 11:33:11
Well Ketan,



This code below should give you a few ideas.



Hope it helps.



Nicholas Murray.



<%@ LANGUAGE=VBSCRIPT %>

<% OPTION EXPLICIT %>

<html><head><title>Pass array from javascript</title>

<SCRIPT LANGUAGE=JavaScript>

function setArray()

{

	var testArray = new Array(1, 2, 3, 4, 5);

	document.frm.hdnArray.value = testArray;

}

</SCRIPT>

<head>



<body>

<form name="frm" action="arraytest.asp" method=post>

<input type=hidden name="hdnArray" value="">

<%

Response.Write "The Array is " & Request.Form("hdnArray")

%>

<br><input type="submit" value="Post It" onClick="setArray();">

</form>

</body>

</html>



Message #4 by "Ketan G. Deshpande(ISRC)" <kgd@i...> on Tue, 6 Nov 2001 18:39:22 +0530
Hi Nicholas



Thanks for your reply!

I tried the similar solution but my problem is I'm getting the comma

delimited string at the server side and I cannot use split if one of the

values in the array already contains comma in it e.g 

arr(0)=12

arr(1)= "South Block, MainStreet" 

Please let me know if there is any other way out.



Regards,

Ketan Deshpande

VISIT US at:- www.isrcsoft.com



> -----Original Message-----

> From:	Nicholas Murray [SMTP:murray_nicholas@h...]

> Sent:	Tuesday, November 06, 2001 5:03 PM

> To:	ASPToday Discuss

> Subject:	[asptoday_discuss] Re: Passing Arrays from JS file to ASP

> 

> Well Ketan,

> 

> This code below should give you a few ideas.

> 

> Hope it helps.

> 

> Nicholas Murray.

> 

> <%@ LANGUAGE=VBSCRIPT %>

> <% OPTION EXPLICIT %>

> <html><head><title>Pass array from javascript</title>

> <SCRIPT LANGUAGE=JavaScript>

> function setArray()

> {

> 	var testArray = new Array(1, 2, 3, 4, 5);

> 	document.frm.hdnArray.value = testArray;

> }

> </SCRIPT>

> <head>

> 

> <body>

> <form name="frm" action="arraytest.asp" method=post>

> <input type=hidden name="hdnArray" value="">

> <%

> Response.Write "The Array is " & Request.Form("hdnArray")

> %>

> <br><input type="submit" value="Post It" onClick="setArray();">

> </form>

> </body>

> </html>

> 

> 



> kgd@i...


> $subst('Email.Unsub')

Message #5 by "Tulip, Nick S" <nick.s.tulip@c...> on Tue, 6 Nov 2001 08:28:02 -0500

	Can you build your new array based off the string received? I am

just giving my two cents into this matter.



		Dim arr()

		dim tmpstr

		Dim i

		str = request("thestring")



		if str <> "" then

			tmpstr = Split(str, ",")

			for i = LBound(tmpstr) to UBound(tmpstr)

				arr(i) = Trim(tmpstr(i))

			Next

		End if

		



-----Original Message-----

From: Ketan G. Deshpande(ISRC) [mailto:kgd@i...]

Sent: Tuesday, November 06, 2001 8:09 AM

To: ASPToday Discuss

Subject: [asptoday_discuss] Re: Passing Arrays from JS file to ASP





Hi Nicholas



Thanks for your reply!

I tried the similar solution but my problem is I'm getting the comma

delimited string at the server side and I cannot use split if one of the

values in the array already contains comma in it e.g 

arr(0)=12

arr(1)= "South Block, MainStreet" 

Please let me know if there is any other way out.



Regards,

Ketan Deshpande

VISIT US at:- www.isrcsoft.com



> -----Original Message-----

> From:	Nicholas Murray [SMTP:murray_nicholas@h...]

> Sent:	Tuesday, November 06, 2001 5:03 PM

> To:	ASPToday Discuss

> Subject:	[asptoday_discuss] Re: Passing Arrays from JS file to ASP

> 

> Well Ketan,

> 

> This code below should give you a few ideas.

> 

> Hope it helps.

> 

> Nicholas Murray.

> 

> <%@ LANGUAGE=VBSCRIPT %>

> <% OPTION EXPLICIT %>

> <html><head><title>Pass array from javascript</title>

> <SCRIPT LANGUAGE=JavaScript>

> function setArray()

> {

> 	var testArray = new Array(1, 2, 3, 4, 5);

> 	document.frm.hdnArray.value = testArray;

> }

> </SCRIPT>

> <head>

> 

> <body>

> <form name="frm" action="arraytest.asp" method=post>

> <input type=hidden name="hdnArray" value="">

> <%

> Response.Write "The Array is " & Request.Form("hdnArray")

> %>

> <br><input type="submit" value="Post It" onClick="setArray();">

> </form>

> </body>

> </html>

> 

> 



> kgd@i...


> $subst('Email.Unsub')





nick.s.tulip@c...


$subst('Email.Unsub')

Message #6 by "Nicholas Murray" <murray_nicholas@h...> on Tue, 6 Nov 2001 14:27:26
Well Ketan,



You could modify the javascript function like I did below to produce a 

string containing in this case "++++" as a delimiter for your VBScript 

split function.



function setArray()

{

	var testArray = new Array(1, "South Block, MainStreet", 3, 4, 5);

	var strTemp = "";

	var i = 0;

	for (i = 0; i < testArray.length; i++) {

		strTemp = strTemp + testArray[i] + "++++";

	}

	document.frm.hdnArray.value = strTemp;

}





Thus producing the string - 1++++hello, there++++3++++4++++5++++ .



Which you can split using the VBScript



<%

Dim TempArray

Dim i

TempArray = Split(Request.Form("hdnArray"), "++++")

Response.Write "The Array contains :" & "<br>"

For i = 0 To Ubound(TempArray)

	Response.Write TempArray(i) & "<br>"

Next

%>



Producing



The Array contains :

1

South Block, MainStreet

3

4

5



Nicholas Murray.







> Hi Nicholas

> 

> Thanks for your reply!

> I tried the similar solution but my problem is I'm getting the comma

> delimited string at the server side and I cannot use split if one of the

> values in the array already contains comma in it e.g 

> arr(0)=12

> arr(1)= "South Block, MainStreet" 

> Please let me know if there is any other way out.

> 

> Regards,

> Ketan Deshpande

> VISIT US at:- www.isrcsoft.com

> 

Message #7 by "Ketan G. Deshpande(ISRC)" <kgd@i...> on Wed, 7 Nov 2001 09:50:10 +0530
Hi Nicholas,



Thanks A Lot! 

My Problem is solved



Regards,

Ketan Deshpande

Information Systems Resource Center Ltd.

Tel  :(91-20)5411581/82 

Fax :(91-20)5411585

(For SMS Problems/Communication please CC mails to SMS Help Desk (ISRC) -

smshd@i...)

VISIT US at:- www.isrcsoft.com



> -----Original Message-----

> From:	Nicholas Murray [SMTP:murray_nicholas@h...]

> Sent:	Tuesday, November 06, 2001 7:57 PM

> To:	ASPToday Discuss

> Subject:	[asptoday_discuss] Re: Passing Arrays from JS file to ASP

> 

> Well Ketan,

> 

> You could modify the javascript function like I did below to produce a 

> string containing in this case "++++" as a delimiter for your VBScript 

> split function.

> 

> function setArray()

> {

> 	var testArray = new Array(1, "South Block, MainStreet", 3, 4, 5);

> 	var strTemp = "";

> 	var i = 0;

> 	for (i = 0; i < testArray.length; i++) {

> 		strTemp = strTemp + testArray[i] + "++++";

> 	}

> 	document.frm.hdnArray.value = strTemp;

> }

> 

> 

> Thus producing the string - 1++++hello, there++++3++++4++++5++++ .

> 

> Which you can split using the VBScript

> 

> <%

> Dim TempArray

> Dim i

> TempArray = Split(Request.Form("hdnArray"), "++++")

> Response.Write "The Array contains :" & "<br>"

> For i = 0 To Ubound(TempArray)

> 	Response.Write TempArray(i) & "<br>"

> Next

> %>

> 

> Producing

> 

> The Array contains :

> 1

> South Block, MainStreet

> 3

> 4

> 5

> 

> Nicholas Murray.

> 

> 

> 

> > Hi Nicholas

> > 

> > Thanks for your reply!

> > I tried the similar solution but my problem is I'm getting the comma

> > delimited string at the server side and I cannot use split if one of the

> > values in the array already contains comma in it e.g 

> > arr(0)=12

> > arr(1)= "South Block, MainStreet" 

> > Please let me know if there is any other way out.

> > 

> > Regards,

> > Ketan Deshpande

> > VISIT US at:- www.isrcsoft.com

> > 

> 



> kgd@i...


> $subst('Email.Unsub')


  Return to Index