WebStyler
WebStyler

Reputation: 35

Passing a var from script in classic asp?

I have this script

<script src="myscript.js" type="text/javascript"></script>
<script type="text/javascript">
var myvalue = (value-from-myscript.js);
document.write (myvalue);
</script>

"document.write" works fine inside the script but how can I get "myvalue" and use it inside classic asp?

How can I make this work?

<%
pmyvalue = "myvalue"
pmyvalue2 = "myvalue2"
pmyvalue3 = "myvalue2"
mySQL="INSERT INTO mytable (value, value2, value3) VALUES ('"pmyvalue"','"pmyvalue2"','"pmyvalue3"')"
%> 

I have "myvalue2" and "myvalue3" on this page

Thanks

Upvotes: 0

Views: 75

Answers (1)

STLDev
STLDev

Reputation: 6164

The reason that this fails is because the second script, the one between <% and %>, is a server-side script that executes on the server. It's executed as the page is emitted from the server. The value you're trying to grab exists only in the browser, so therefore this fails.

Rather than doing this in a server-side script, you need to call a method on the server, or call the page a second time, passing the value you want to insert.

Upvotes: 1

Related Questions