-
pass data from asp to javascript in the same page
How can I pass ASP variables to javascript variables
(in the same page)?
Thanx in advance.
Tim
-
Re: pass data from asp to javascript in the same page
Here is an example which puts the value of a VBScript variable into a JavaScript
alert box:
Response.Write "<script language='JavaScript'>alert('The value is " & MyVBScriptVariable
& "');</script>"
Best regards,
-Paul
J. Paul Schmidt, MBA
Databases on the Web
http://www.Bullschmidt.com
-
Re: pass data from asp to javascript in the same page
Hi Tim,
Here is a simple way to use a variable declared in ASP in JavaScript:
<%
Dim varASP 'a variable in asp
varASP = "Some value"
%>
<SCRIPT LANGUAGE="JavaScript">
<!--
function ShowValue() {
window.alert('<% = varASP %>')
}
-->
</SCRIPT>
Just make sure that the asp variable is declared and initialized before being
used in the JavaScript part.
Hope this one helps !
Dylan.
"Tim" <sam213@cdg.com> wrote:
>
>How can I pass ASP variables to javascript variables
>(in the same page)?
>
>Thanx in advance.
>Tim
-
Re: pass data from asp to javascript in the same page
Yes,
All above methods work fine, but I still believe in:
<SCRIPT Language="JavaScript">
varName = "<%=strName%>"
...
...
</SCRIPT>
This actually 'copies' the variable to client side that can be 'used' anywhere
in client side
Cheers
Rohit
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|