Passing a value from ASP to the script 
Author Message
 Passing a value from ASP to the script

Could you help me? I am new to Jscript, how could I pass in an ASP page, a
value to a script.

Page.asp:

<% a bit of ASP
I set a path and store it in a variable that I want to pass to my script
%>

<script>
I get my variable (my path)
and use it in my script

(a script to access the fso object)
<script>

<% redirect in asp to another page%>



Sun, 23 Jun 2002 03:00:00 GMT  
 Passing a value from ASP to the script
Insert an ASP variable directly into the client script, like this:

<script>
        windows.framename.location.href='<%=ASPvariable%>';
</script>

IF the ASPVariable is set to "page.asp" you'll get on the browser:

<script>
        windows.framename.location.href='page.asp';
</script>

Alexandre Pinho
Portugal


Quote:
> Could you help me? I am new to Jscript, how could I pass in an ASP page, a
> value to a script.

> Page.asp:

> <% a bit of ASP
> I set a path and store it in a variable that I want to pass to my script
> %>

> <script>
> I get my variable (my path)
> and use it in my script

> (a script to access the fso object)
> <script>

> <% redirect in asp to another page%>



Sun, 23 Jun 2002 03:00:00 GMT  
 Passing a value from ASP to the script
Absolutely not true.  You can't pass server side variables to client side
script directly.

You can however store a server side variable in a hidden input box and then
refer to the variable in script.  Hence in the example given below you can
store the variable like this:

<input type="hidden" name="myvar" value="<%ASPvariable%>">

Then refer to it as:

<script>
       windows.framename.location.href='document.myform.myvar.value';
 </script>



Quote:
> Insert an ASP variable directly into the client script, like this:

> <script>
>         windows.framename.location.href='<%=ASPvariable%>';
> </script>

> IF the ASPVariable is set to "page.asp" you'll get on the browser:

> <script>
>         windows.framename.location.href='page.asp';
> </script>

> Alexandre Pinho
> Portugal



> > Could you help me? I am new to Jscript, how could I pass in an ASP page,
a
> > value to a script.

> > Page.asp:

> > <% a bit of ASP
> > I set a path and store it in a variable that I want to pass to my script
> > %>

> > <script>
> > I get my variable (my path)
> > and use it in my script

> > (a script to access the fso object)
> > <script>

> > <% redirect in asp to another page%>



Sun, 23 Jun 2002 03:00:00 GMT  
 Passing a value from ASP to the script
Hi

Or

Response.Write("<script language='javascript'>MyVar1=" + bla1 + ";MyVar2="
+bla2+ ";</script>");

he
--
Best Regards
   Vidar Petursson
http://www.icysoft.com


-

Quote:
> Absolutely not true.  You can't pass server side variables to client side
> script directly.

> You can however store a server side variable in a hidden input box and
then
> refer to the variable in script.  Hence in the example given below you can
> store the variable like this:

> <input type="hidden" name="myvar" value="<%ASPvariable%>">

> Then refer to it as:

> <script>
>        windows.framename.location.href='document.myform.myvar.value';
>  </script>



> > Insert an ASP variable directly into the client script, like this:

> > <script>
> >         windows.framename.location.href='<%=ASPvariable%>';
> > </script>

> > IF the ASPVariable is set to "page.asp" you'll get on the browser:

> > <script>
> >         windows.framename.location.href='page.asp';
> > </script>

> > Alexandre Pinho
> > Portugal



> > > Could you help me? I am new to Jscript, how could I pass in an ASP
page,
> a
> > > value to a script.

> > > Page.asp:

> > > <% a bit of ASP
> > > I set a path and store it in a variable that I want to pass to my
script
> > > %>

> > > <script>
> > > I get my variable (my path)
> > > and use it in my script

> > > (a script to access the fso object)
> > > <script>

> > > <% redirect in asp to another page%>



Sun, 23 Jun 2002 03:00:00 GMT  
 Passing a value from ASP to the script
While your hidden input box will work, what Alexandre posted will also work.  If you would read
his post, you will notice that he is not directly assigning a server side variable to a client
side variable, but doing the equivelent to what you are doing to get the value into the hidden
input - except that he didn't forget the '='.  Your

value="<%ASPvariable%>">

should be

value="<%=ASPvariable%>">

Vincent Minden

Quote:

> Absolutely not true.  You can't pass server side variables to client side
> script directly.

> You can however store a server side variable in a hidden input box and then
> refer to the variable in script.  Hence in the example given below you can
> store the variable like this:

> <input type="hidden" name="myvar" value="<%ASPvariable%>">

> Then refer to it as:

> <script>
>        windows.framename.location.href='document.myform.myvar.value';
>  </script>



> > Insert an ASP variable directly into the client script, like this:

> > <script>
> >         windows.framename.location.href='<%=ASPvariable%>';
> > </script>

> > IF the ASPVariable is set to "page.asp" you'll get on the browser:

> > <script>
> >         windows.framename.location.href='page.asp';
> > </script>

> > Alexandre Pinho
> > Portugal



> > > Could you help me? I am new to Jscript, how could I pass in an ASP page,
> a
> > > value to a script.

> > > Page.asp:

> > > <% a bit of ASP
> > > I set a path and store it in a variable that I want to pass to my script
> > > %>

> > > <script>
> > > I get my variable (my path)
> > > and use it in my script

> > > (a script to access the fso object)
> > > <script>

> > > <% redirect in asp to another page%>



Mon, 24 Jun 2002 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Passing values between an ASP page and an HTA - VBS script

2. ASP : Passing values from One ASP to the Next

3. Passing value from Server script to client script.

4. How can pass a value from Vb script to java script

5. Problem of Passing value from .asp to .vbs

6. Passing SELECT values to ASP

7. Passing SELECT Values to ASP

8. Please Help - Passing SELECT values to ASP

9. Passing a Value from JavaScript back to ASP

10. Passing Values to asp page

11. Passing Values to another asp file from inside VbScript

12. Frames and ASP and passing parameters / values

 

 
Powered by phpBB® Forum Software