Solved

Accessing javascript variable inside asp tags

Posted on 2004-04-27
5
394 Views
Last Modified: 2008-03-10
Is there anyway to access the Javascript variable inside ASP or HTML?
i ve one variable inside javascript that variable's value i want to display inside ASP tags?
can it be done?


raja
0
Comment
  • 2
5 Comments
 
LVL 5

Accepted Solution

by:
chaniewskim earned 20 total points
ID: 10927136
No easy way.
JS is client-side, ASP is server-side. You can only pass data from client-side to server-side using QueryString or Form collecion, which implies refreshing a page. For example you could create a link:

<a href=# onclick="location.href='mypage.asp?myvariable=' + myVariable;">xxx</a>

then use Request("myvariable") to retrieve argument
0
 
LVL 1

Expert Comment

by:i_rajeevsingh
ID: 10935763
Sure
No way

You can use query string and submit to fetch data from fields
and for the variables you can store them in Hidden Fields and get at the server

Moreover youcan assign value to Client Side Variable through the Server Side Scripting
Like in ASP
It is like

<%my_text="Hello"%>
<script langugae="Javascript">
function test
{
str=<%=my_text%>;
alert(str);
}
</script>

Regards
Rajeev
0
 
LVL 1

Expert Comment

by:i_rajeevsingh
ID: 11341057
Please Close and distribute the points accordingly
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now