Passing variable between client and server 
Author Message
 Passing variable between client and server

I had an idea that when a user finds a broken link it would be cool for the
web team to know where the link is and where it is pointing to.

I wrote the following code (sensitive information omitted here) but the
variables created in the <SCRIPT> tag aren't available to the <% %> script
tag.


<HTML>
<HEAD>
<Script language=Javascript>
var NumPages = window.history.length -2
var LastPage = window.history[NumPages]
var RequestedPage =  window.history.previous
</script>
<TITLE></TITLE>
</HEAD>

<BODY>
<%
Mail = Server.CreateObject("CDONTS.NewMail");
Mail.From = "Automated_from_website";
Mail.To = xxx
Mail.Subject = "Test Message"
Mail.Body = "The following page has a broken link: " + ("LastPage") + "
The link goes to: " + ("RequestedPage")
Mail.Send();
%>
<FORM ACTION="<%Request.ServerVariables("Script_Name")%>" METHOD=POST>

I would really apreciate any pointers you guys could give.



Fri, 16 May 2003 03:00:00 GMT  
 Passing variable between client and server
Gerard,
The client side vars are not directly accessible to server side code.  The
easiest way to pass them would be to create 3 hidden form elements, and
initialize them with 'document.form1.element1.value = NumPages', etc. in
your client side script.  Then, when the form is submitted, you retrieve
them from the server-side Request.Form() object and send the message.

Rob.


Quote:
> I had an idea that when a user finds a broken link it would be cool for
the
> web team to know where the link is and where it is pointing to.

> I wrote the following code (sensitive information omitted here) but the
> variables created in the <SCRIPT> tag aren't available to the <% %> script
> tag.


> <HTML>
> <HEAD>
> <Script language=Javascript>
> var NumPages = window.history.length -2
> var LastPage = window.history[NumPages]
> var RequestedPage =  window.history.previous
> </script>
> <TITLE></TITLE>
> </HEAD>

> <BODY>
> <%
> Mail = Server.CreateObject("CDONTS.NewMail");
> Mail.From = "Automated_from_website";
> Mail.To = xxx
> Mail.Subject = "Test Message"
> Mail.Body = "The following page has a broken link: " + ("LastPage") + "
> The link goes to: " + ("RequestedPage")
> Mail.Send();
> %>
> <FORM ACTION="<%Request.ServerVariables("Script_Name")%>" METHOD=POST>

> I would really apreciate any pointers you guys could give.




Fri, 16 May 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Pass client script variable to server script variable

2. Help: problem passing variable between client/server scripts

3. Passing Variables from Server to Client

4. Urgent : Passing variables from client script to server side

5. Passing variables from server-side to client-side

6. Passing variables from client-side to server-side

7. Help: problem passing variable between client/server scripts

8. passing variables from server to client?

9. Passing variable from server side to client side

10. passing client variables to the server

11. Passing arrays from a server-function/sub to a server -variable

12. Assigning Client Script Variables to Application level variables inside of a Client Script

 

 
Powered by phpBB® Forum Software