Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why msgbox doen't work in <%@ Language=VBScript %>?

Status
Not open for further replies.

snr

Programmer
Oct 8, 2001
78
US
Why msgbox doen't work in <%@ Language=VBScript %> ?
why we have to write
<script Language=&quot;vbscript&quot;>
Dim MyVar
MyVar = MsgBox (&quot;TEST msgbox ! &quot;,4)
</script>

And even I can't access this myvar value outside this script.How can I access that variable ? as session also doen't work in <script></script>
 
<%
This is server side script
%>

<script>
This is client side script
</script>

msgbox is a client side object, which is why it doesn't work server side.

session variables are server side, which is why you can't access them from client side script.

:)
paul
penny.gif
penny.gif
 
If you use <% and %> instead of the <script> tags for your server side code, you can actually do what you want.

<%
Dim MyMsg
MyMsg = &quot;TEST msgbox ! &quot;
%>
<Script language=JavaScript>
alert(<%=MyMsg%>);
</Script>

Alternatively, you can write the JavaScript using the Response.write method. The important this is that the Serverside code needs to be marked with the <% and %> symbols so the compiler processes the tags correctly.

BTW, the code will stop processing while the alert box is displayed. If you use the prompt method in JavaScript, you can receive a user's response. However, since that's Client-side you can't pull it back into your server-side code.

Dave Robinder
 
Yes .... I understood the point, but the problem I am facing is , depending on the users response , i.e YES or NO , I want to update the rows in the table.
So in msgbox I can specify these options. But How can I collect the user's response , in some variable , which I can use for the decision ?
 
Try using a confirm box when using client-side code. This will give you two buttons to work with (OK - Cancel).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top