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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I use vbscript to write out a javascript alert 2

Status
Not open for further replies.

scc

Programmer
Apr 30, 2001
218
US
If I process some code on the server, and the value the user is posting is "out of range" for the application, how can I display a message box to the user.

I assume that I would have to have my vbscript write out a javascript alert box, but not sure how to do that.

TIA for any help on this!
 
You could something like this....

Put the following up in the header of the ASP page....

<script language=JavaScript>
function AlertUser(val)
{
if (confirm(&quot;Out of range&quot;) == true)
{
window.navigate(&quot;someotherpage.asp?action=del&SiteID=&quot;+SiteID);
}
}
</script>

then when you load the ASP page ( or results showing out of range ) , if the value is out of range re-write the BODY onload argument in the body tag.

FOr example....

<%

if rs.EOF Then ('or out of range value)
response.write &quot;<BODY onload=&quot;&quot;AlertUser(1)&quot;&quot;>&quot;
Else
response.write &quot;<BODY>&quot;
End IF

%>


Hope that helps.....

_______________________________________________
OutsideIntranets.com
Stop wasting time, get to work
 
Here's my problem with this, I already have an onload event being called, call I call 2?
 
what if you use a variable, like gOutofRange. In the appropriate event (maybe onbeforeupdate), set it to &quot;yes&quot; if the entry is out of range. Down in your html, put:

<%if gOutofRange = &quot;yes&quot; then%>
<script language=javascript>
alert(&quot;don't do that&quot;);
</script>
<%end if%>

This will take some work to make sure the variable always equals what it is supposed to equal, but you can probably do whatever you need to do with it.
 
Answer 1: Yes, you can call more than one event on the onLoad.

Answer 2: Maybe this will work for you:

Response.Write &quot;<SCRIPT language=&quot;&quot;JavaScript&quot;&quot;>alert(&quot;&quot;your message here&quot;&quot;) & &quot;&quot;&quot;);</SCRIPT>&quot; & vbcrlf

(watch for line wrapping)
I use this quite often after a page is posted to show values of different things.

HTH. Tim
 
You can call more then one thing on onLoad event, seperate each event with a semi colon (;)

onLoad=&quot;MsgAlert('This is a message')&quot;;window.close()&quot;

or whatever you call.. www.vzio.com
ASP WEB DEVELOPMENT



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top