Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Passing parameters from VBScript to Javascript


Message #1 by "william" <william@t...> on Wed, 26 Sep 2001 12:36:31
Please help me urgently

How do I pass a value like

<%myValue = "1,2,3,4"%> ...in VBScript

to A funciton in Javascript



like



<script>



function passValue(the value above)

{

'or to get the value of myValue parameter inside the funcion

}

</script>
Message #2 by "Johnson, Israel" <IJohnson@R...> on Wed, 26 Sep 2001 07:49:34 -0400
Try using an array to store it then pull it using a for each to dynamically

build your javascript

_______________

Dim value()

value[0] = "1"

value[1] = "2"

value[2] = "3"

value[3] = "4"



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

From: william [mailto:william@t...]

Sent: Wednesday, September 26, 2001 8:37 AM

To: ASP Web HowTo

Subject: [asp_web_howto] Passing parameters from VBScript to Javascript





Please help me urgently

How do I pass a value like

<%myValue = "1,2,3,4"%> ...in VBScript

to A funciton in Javascript



like



<script>



function passValue(the value above)

{

'or to get the value of myValue parameter inside the funcion

}

</script>




$subst('Email.Unsub')

Message #3 by "Daniel O'Dorisio" <dodorisio@h...> on Wed, 26 Sep 2001 08:00:27 -0400
Easier then you think. But harder then you hoped:-)



j/k

It actually is pretty simple, I do it like this:



Dim vbsVar

vbsVar = "hello world"



With Response

	.write "<script language=javascript>" &vbcrlf

	.write "function getvbsvar{" &vbcrlf

	.write "jscriptVar=" &vbsVar & ";"&vbcrlf

	.write "}"&vbcrlf

	.write "</script>"&vbcrlf

End with



That way you can just write out the value of the var to the javascript

section. You can also do your script like normal but then just do a lot

of context switching, using <%=somevar%>. Think of it like this.

Anything in asp is strictly server side. With no communications to the

browser, untill you use the response object, (or if you have html in

your page) no content will be sent to the browser. Also remember that

javascript is clientside (can be serverside...but you know) and it can

only act on the client untill it changes window.location, or

form.submit() or whatever else that tells the browser to send something

to the server. 



So then, since we have these 2 principles. In order to get a var from

server to client, we must use the response.write method to "send" the

value of that variable down to the client inline with the script we are

sending down. They are then able to use that value.





Hth.



daniel



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

From: william [mailto:william@t...] 

Sent: Wednesday, September 26, 2001 12:37 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Passing parameters from VBScript to Javascript





Please help me urgently

How do I pass a value like

<%myValue = "1,2,3,4"%> ...in VBScript

to A funciton in Javascript



like



<script>



function passValue(the value above)

{

'or to get the value of myValue parameter inside the funcion

}

</script>

---

You are currently subscribed to asp_web_howto as: dodorisio@h... To

unsubscribe send a blank email to

$subst('Email.Unsub')





Message #4 by "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> on Wed, 26 Sep 2001 13:23:30 +0100
put it in a hidden field then use javascript to extract the value from the

field



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

From: william [mailto:william@t...]

Sent: 26 September 2001 13:37

To: ASP Web HowTo

Subject: [asp_web_howto] Passing parameters from VBScript to Javascript





Please help me urgently

How do I pass a value like

<%myValue = "1,2,3,4"%> ...in VBScript

to A funciton in Javascript



like



<script>



function passValue(the value above)

{

'or to get the value of myValue parameter inside the funcion

}

</script>



________________________________________________________________________

Scottish Enterprise Network

http://www.scottish-enterprise.com



Message #5 by "William Raphela" <william@t...> on Tue, 25 Sep 2001 14:16:46 +0200
Thanks Johnson



But how do I refer to the value you just created inside a javascript funtion

thanks in advance



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

From: Johnson, Israel <IJohnson@R...>

To: ASP Web HowTo <asp_web_howto@p...>

Sent: Wednesday, September 26, 2001 1:49 PM

Subject: [asp_web_howto] RE: Passing parameters from VBScript to Javascrip t





> Try using an array to store it then pull it using a for each to

dynamically

> build your javascript

> _______________

> Dim value()

> value[0] = "1"

> value[1] = "2"

> value[2] = "3"

> value[3] = "4"

>

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

> From: william [mailto:william@t...]

> Sent: Wednesday, September 26, 2001 8:37 AM

> To: ASP Web HowTo

> Subject: [asp_web_howto] Passing parameters from VBScript to Javascript

>

>

> Please help me urgently

> How do I pass a value like

> <%myValue = "1,2,3,4"%> ...in VBScript

> to A funciton in Javascript

>

> like

>

> <script>

>

> function passValue(the value above)

> {

> 'or to get the value of myValue parameter inside the funcion

> }

> </script>

>

Message #6 by "Johnson, Israel" <IJohnson@R...> on Wed, 26 Sep 2001 09:02:12 -0400
Place the for each into the function param area.   Use the response.write

for your loop.  Something like this... 



> function passValue(

<% For Each Item in Value 

	Response.write Item & ","

Next %>)

 {

 'or to get the value of myValue parameter inside the funcion

}

</script>



or 



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

From: William Raphela [mailto:william@t...]

Sent: Tuesday, September 25, 2001 8:17 AM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Passing parameters from VBScript to

Javascrip t





Thanks Johnson



But how do I refer to the value you just created inside a javascript funtion

thanks in advance



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

From: Johnson, Israel <IJohnson@R...>

To: ASP Web HowTo <asp_web_howto@p...>

Sent: Wednesday, September 26, 2001 1:49 PM

Subject: [asp_web_howto] RE: Passing parameters from VBScript to Javascrip t





> Try using an array to store it then pull it using a for each to

dynamically

> build your javascript

> _______________

> Dim value()

> value[0] = "1"

> value[1] = "2"

> value[2] = "3"

> value[3] = "4"

>

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

> From: william [mailto:william@t...]

> Sent: Wednesday, September 26, 2001 8:37 AM

> To: ASP Web HowTo

> Subject: [asp_web_howto] Passing parameters from VBScript to Javascript

>

>

> Please help me urgently

> How do I pass a value like

> <%myValue = "1,2,3,4"%> ...in VBScript

> to A funciton in Javascript

>

> like

>

> <script>

>

> function passValue(the value above)

> {

> 'or to get the value of myValue parameter inside the funcion

> }

> </script>

>






$subst('Email.Unsub')


  Return to Index