Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: mixing asp with js


Message #1 by "Suhail kaleem" <suhailkaleem@p...> on Sat, 14 Dec 2002 02:00:59
hi !
how do  i equal  the js variable value to the asp variable value ?

var pagehtml="<html>\n<head>\n<meta http-equiv=\"Content-Type\" 
content=\"text/html; " +
"charset=windows-1252\">\n<meta name=\"GENERATOR\" 
content=\"PageCreate\">\n" +
"<title>New Page</title>\n</head>\n<body> <br> <br> <%=session("varbody")%
>" +
" <br> \n</body>\n</html>";


now if the session("varbody")  conatins " or any other js iligal 
character  it will produce a error  in js script  like line feeds/line 
breaks   so how do i fix it ? 

Thnaks
suhailkaleem
Message #2 by Greg Griffiths <greg2@s...> on Sat, 14 Dec 2002 19:33:35 +0000
Take a look at the REPLACE command in VBScript

At 02:00 14/12/02 +0000, you wrote:
>hi !
>how do  i equal  the js variable value to the asp variable value ?
>
>var pagehtml="<html>\n<head>\n<meta http-equiv=\"Content-Type\"
>content=\"text/html; " +
>"charset=windows-1252\">\n<meta name=\"GENERATOR\"
>content=\"PageCreate\">\n" +
>"<title>New Page</title>\n</head>\n<body> <br> <br> <%=session("varbody")%
> >" +
>" <br> \n</body>\n</html>";
>
>
>now if the session("varbody")  conatins " or any other js iligal
>character  it will produce a error  in js script  like line feeds/line
>breaks   so how do i fix it ?
>
>Thnaks
>suhailkaleem



Message #3 by "Suhail kaleem" <suhailkaleem@p...> on Sat, 14 Dec 2002 20:18:26
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>

<body>

<font face="Verdana, Arial, Helvetica">
<table cellSpacing="0" cellPadding="0" width="95%" align="center" 
border="0">
  <tr>
    <td bgColor="black">
    <table cellSpacing="1" cellPadding="4" width="100%" border="0">
      <tr>
        <td vAlign="top" bgColor="whitesmoke" colSpan="2">
        <font face="Verdana, Arial, Helvetica" color="midnightblue" 
size="2">hi
        <br>
        Thanks for the info ! <br>
        but what i am trying to do is to make asp fucntion that will 
completely 
        convert HTML TO JAVASCRIPT <br>
        here is what i came up with but still there are errors <br>
&nbsp;<pre id="code"><font id="code" face="courier" size="2"> 
&lt;html&gt;
&lt;body&gt;</pre>
        <p>&lt;%<br>
        if request.form &lt;&gt; &quot;&quot; then <br>
        vart=replace(request.form
(&quot;S1&quot;),&quot;&quot;&quot;&quot; ,&quot;\&quot;&quot;&quot;)<br>
        vart= replace (vart,&quot;/&quot;,&quot;//&quot;)<br>
        vart= replace (vart,Chr(13),&quot;\n&quot;)<br>
        vart= replace (vart,Chr(10),&quot;\n&quot;)<br>
        response.write vart <br>
        response.write &quot;&lt;p&gt;&lt;textarea 
rows=&quot;&quot;4&quot;&quot; name=&quot;&quot;S1&quot;&quot; 
        
cols=&quot;&quot;22&quot;&quot;&gt;&quot;&amp;vart&amp;&quot;&lt;/textarea&
gt;&lt;/p&gt;&quot;<br>
        end if <br>
        %&gt;<br>
        &lt;script language=&quot;JavaScript&quot;&gt;<br>
        &lt;!--</p>
        <p>var pagehtml=&quot;&lt;%=vart%&gt;&quot;;</p>
        <p>document.writeln(pagehtml);<br>
        document.writeln(&quot; &lt;p&gt;&lt;textarea rows=\&quot;4\&quot; 
name=\&quot;S1\&quot; 
        cols=\&quot;22
\&quot;&gt;&quot;+pagehtml+&quot;&lt;//textarea&gt;&lt;//p&gt;&quot;);</p>
        <p><br>
        --&gt;</p>
        <p>&lt;/script&gt;</p>
        <p>&lt;form method=&quot;POST&quot;&gt;<br>
        &lt;p&gt;&nbsp;&lt;/p&gt;<br>
        &lt;p&gt;&lt;textarea rows=&quot;4&quot; name=&quot;S1&quot; 
cols=&quot;22&quot;&gt;&lt;/textarea&gt;&lt;/p&gt;<br>
        &lt;p&gt;&lt;input type=&quot;submit&quot; 
value=&quot;Submit&quot; name=&quot;B1&quot;&gt;&lt;input 
type=&quot;reset&quot; 
        value=&quot;Reset&quot; name=&quot;B2&quot;&gt;&lt;/p&gt;<br>
        &lt;p&gt;&nbsp;&lt;/p&gt;<br>
        &lt;/form&gt;</p>
        <p>&nbsp;</p>
        <p>&lt;/body&gt;</p>
        <p>&lt;/html&gt;<br>
&nbsp;</font></p>
        <pre>&nbsp;</pre>
        <p>&nbsp;</p>
        <p>let me know if i am going in the write direction <br>
        Thanks</font></td>
      </tr>
    </table>
    </td>
  </tr>
</table>
</font>

</body>

</html>
Message #4 by "Suhail kaleem" <suhailkaleem@p...> on Sat, 14 Dec 2002 20:20:41
<font face="Verdana, Arial, Helvetica">
<p><font face="Verdana, Arial, Helvetica" color="midnightblue" size="2">hi 
<br>
Thanks for the info ! <br>
but what i am trying to do is to make asp fucntion that will completely 
convert 
HTML TO JAVASCRIPT <br>
here is what i came up with but still there are errors <br>
&nbsp;</p>
<pre id="code"><font id="code" face="courier" size="2"> 
&lt;html&gt;
&lt;body&gt;</pre>
<p>&lt;%<br>
if request.form &lt;&gt; &quot;&quot; then <br>
vart=replace(request.form
(&quot;S1&quot;),&quot;&quot;&quot;&quot; ,&quot;\&quot;&quot;&quot;)<br>
vart= replace (vart,&quot;/&quot;,&quot;//&quot;)<br>
vart= replace (vart,Chr(13),&quot;\n&quot;)<br>
vart= replace (vart,Chr(10),&quot;\n&quot;)<br>
response.write vart <br>
response.write &quot;&lt;p&gt;&lt;textarea rows=&quot;&quot;4&quot;&quot; 
name=&quot;&quot;S1&quot;&quot; 
cols=&quot;&quot;22&quot;&quot;&gt;&quot;&amp;vart&amp;&quot;&lt;/textarea&
gt;&lt;/p&gt;&quot;<br>
end if <br>
%&gt;<br>
&lt;script language=&quot;JavaScript&quot;&gt;<br>
&lt;!--</p>
<p>var pagehtml=&quot;&lt;%=vart%&gt;&quot;;</p>
<p>document.writeln(pagehtml);<br>
document.writeln(&quot; &lt;p&gt;&lt;textarea rows=\&quot;4\&quot; 
name=\&quot;S1\&quot; 
cols=\&quot;22
\&quot;&gt;&quot;+pagehtml+&quot;&lt;//textarea&gt;&lt;//p&gt;&quot;);</p>
<p><br>
--&gt;</p>
<p>&lt;/script&gt;</p>
<p>&lt;form method=&quot;POST&quot;&gt;<br>
&lt;p&gt;&nbsp;&lt;/p&gt;<br>
&lt;p&gt;&lt;textarea rows=&quot;4&quot; name=&quot;S1&quot; 
cols=&quot;22&quot;&gt;&lt;/textarea&gt;&lt;/p&gt;<br>
&lt;p&gt;&lt;input type=&quot;submit&quot; value=&quot;Submit&quot; 
name=&quot;B1&quot;&gt;&lt;input type=&quot;reset&quot; 
value=&quot;Reset&quot; name=&quot;B2&quot;&gt;&lt;/p&gt;<br>
&lt;p&gt;&nbsp;&lt;/p&gt;<br>
&lt;/form&gt;</p>
<p>&nbsp;</p>
<p>&lt;/body&gt;</p>
<p>&lt;/html&gt;<br>
&nbsp;</font></p>
<pre>&nbsp;</pre>
<p>&nbsp;</p>
<p>let me know if i am going in the write direction <br>
Thanks</p>
</font></font>






> Take a look at the REPLACE command in VBScript

At 02:00 14/12/02 +0000, you wrote:
>hi !
>how do  i equal  the js variable value to the asp variable value ?
>
>var pagehtml="<html>\n<head>\n<meta http-equiv=\"Content-Type\"
>content=\"text/html; " +
>"charset=windows-1252\">\n<meta name=\"GENERATOR\"
>content=\"PageCreate\">\n" +
>"<title>New Page</title>\n</head>\n<body> <br> <br> <%=session("varbody")%
> >" +
>" <br> \n</body>\n</html>";
>
>
>now if the session("varbody")  conatins " or any other js iligal
>character  it will produce a error  in js script  like line feeds/line
>breaks   so how do i fix it ?
>
>Thnaks
>suhailkaleem



Message #5 by "Suhail kaleem" <suhailkaleem@p...> on Sat, 14 Dec 2002 20:24:27
hi 
Thanks for the info ! 
but what i am trying to do is to make asp fucntion that will completely 
convert HTML TO JAVASCRIPT 
here is what i came up with but still there are errors 

 
<html>
<body>
<%
if request.form <> "" then 
vart=replace(request.form("S1"),"""" ,"\""")
vart= replace (vart,"/","//")
vart= replace (vart,Chr(13),"\n")
vart= replace (vart,Chr(10),"\n")
response.write vart 
response.write "<p><textarea rows=""4"" name=""S1"" 
cols=""22"">"&vart&"</textarea></p>"
end if 
%>
<script language="JavaScript">
<!--
var pagehtml="<%=vart%>";
document.writeln(pagehtml);
document.writeln(" <p><textarea rows=\"4\" name=\"S1\" cols=\"22
\">"+pagehtml+"<//textarea><//p>");

-->
</script>
<form method="POST">
<p> </p>
<p><textarea rows="4" name="S1" cols="22"></textarea></p>
<p><input type="submit" value="Submit" name="B1"><input type="reset" 
value="Reset" name="B2"></p>
<p> </p>
</form>

</body>
</html>



let me know if i am going in the write direction 
Thanks




> hi !
h> ow do  i equal  the js variable value to the asp variable value ?

> var pagehtml="<html>\n<head>\n<meta http-equiv=\"Content-Type\" 
c> ontent=\"text/html; " +
"> charset=windows-1252\">\n<meta name=\"GENERATOR\" 
c> ontent=\"PageCreate\">\n" +
"> <title>New Page</title>\n</head>\n<body> <br> <br> <%=session
("varbody")%
>> " +
">  <br> \n</body>\n</html>";

> 
n> ow if the session("varbody")  conatins " or any other js iligal 
c> haracter  it will produce a error  in js script  like line feeds/line 
b> reaks   so how do i fix it ? 

> Thnaks
s> uhailkaleem
Message #6 by "TomMallard" <mallard@s...> on Mon, 16 Dec 2002 07:45:31 -0800
Try this idea...

<html>
<head>
<script>
function writePage(){
	document.writeln("<html>");
	...
// add your server side logic for grabbing the form values here
	...
	document.writeln("</html>");
	document.close();
}
</script>
<body onload="writePage()">
</body>
</html>

tom mallard
seattle


-----Original Message-----
From: Suhail kaleem [mailto:suhailkaleem@p...]
Sent: Saturday, December 14, 2002 8:24 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Re: mixing asp with js


hi
Thanks for the info !
but what i am trying to do is to make asp fucntion that will completely
convert HTML TO JAVASCRIPT
here is what i came up with but still there are errors


<html>
<body>
<%
if request.form <> "" then
vart=replace(request.form("S1"),"""" ,"\""")
vart= replace (vart,"/","//")
vart= replace (vart,Chr(13),"\n")
vart= replace (vart,Chr(10),"\n")
response.write vart
response.write "<p><textarea rows=""4"" name=""S1""
cols=""22"">"&vart&"</textarea></p>"
end if
%>
<script language="JavaScript">
<!--
var pagehtml="<%=vart%>";
document.writeln(pagehtml);
document.writeln(" <p><textarea rows=\"4\" name=\"S1\" cols=\"22
\">"+pagehtml+"<//textarea><//p>");

-->
</script>
<form method="POST">
<p> </p>
<p><textarea rows="4" name="S1" cols="22"></textarea></p>
<p><input type="submit" value="Submit" name="B1"><input type="reset"
value="Reset" name="B2"></p>
<p> </p>
</form>

</body>
</html>



let me know if i am going in the write direction
Thanks




> hi !
h> ow do  i equal  the js variable value to the asp variable value ?

> var pagehtml="<html>\n<head>\n<meta http-equiv=\"Content-Type\"
c> ontent=\"text/html; " +
"> charset=windows-1252\">\n<meta name=\"GENERATOR\"
c> ontent=\"PageCreate\">\n" +
"> <title>New Page</title>\n</head>\n<body> <br> <br> <%=session
("varbody")%
>> " +
">  <br> \n</body>\n</html>";

>
n> ow if the session("varbody")  conatins " or any other js iligal
c> haracter  it will produce a error  in js script  like line feeds/line
b> reaks   so how do i fix it ?

> Thnaks
s> uhailkaleem



  Return to Index