Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
shajimanjeri
Posting Yak Master
179 Posts |
Posted - 2007-06-03 : 01:06:03
|
How to pass a javascript value to a ASP.For eg:- I have a javascript variable with value = 1<script>var i = 1</script>now I wrote one sql query like this:-<%query = "select * from Messages where Id = [Here I need to put that javacript variable]"%> So how to pass this javascript value to this query.Please help me!!with regardsShaji |
|
cvraghu
Posting Yak Master
187 Posts |
Posted - 2007-06-04 : 17:32:20
|
1. You've to set a session variable from client side script. You can use XMLHTTP to post the variable to another asp page and set the session value there.2. Access the session variable in the current asp script.The code would be simpler. But if you post the complete scenario, may be someone would provide a better design. |
|
|
shajimanjeri
Posting Yak Master
179 Posts |
Posted - 2007-06-05 : 02:55:28
|
Thanks cvraghu,Ok. Now just give me a simple way to pass a javscript value to a asp variable.Like<script>var x = 1</script>I am using classic aspI need to pass this value to a asp variable<%dim yy = [here I need to bring that javascript variable value]%>how we are doing in normal way.shaji |
|
|
cvraghu
Posting Yak Master
187 Posts |
Posted - 2007-06-05 : 13:15:13
|
I've posted my solution already. Did you tried it? 1. Why the variable value cannot be passed as query string from previous page to this page?2. Why can't you have a simple redirect which will pass this value to the asp?3. Why you can't store the value of the variable in hidden control and post to this page?If using javascript variable in asp is the only option, i'm not sure of any other way other than what i provided. |
|
|
rudesyle
Posting Yak Master
110 Posts |
Posted - 2007-06-06 : 14:38:32
|
Not trying to be mean, but do you understand what you are doing? The javascript will be run on the client(in the browser). The ASP gets run on the server. If you have a value you want the client to send to the server (to run your query), then you need to send it in a page request in either a querystring or form field. |
|
|
|
|
|