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

Auto-pop up window with ASP

Status
Not open for further replies.

BG12424

Programmer
Jun 4, 2002
717
0
0
US
I am having difficulty getting this to work. I am executing a stored procedure in a function and if there is an error, I would like to open a popup window with the error message. I am trying to do the following after the function call.

The error that I am getting is that I am missing a ")", but I can't seem to find where.

<%

if retval > 0 then

dim msg
msg=&quot;An error occurred&quot;
Response.Write(&quot;<SCRIPT>window.open('error.asp?msg='&quot; & msg & &quot;','ErrorPage','WIDTH=635,HEIGHT=400,scrollbars=no,resizable=no,status=yes')</SCRIPT>&quot;)

end if
%>

Thanks regards,
Brian
 
I believe you can't write ASP code within the <SCRIPT> tag. That's been my experience. I could be mistaken.
 
Oops.
What would be a work around to do this? do you have an source code for this? thanks
regards,
Brian
 
Use this:
Response.Write(&quot;<SCRIPT>&quot; & &quot;window.open('error.asp?msg=&quot; & msg & &quot;','ErrorPage','WIDTH=635,HEIGHT=400,scrollbars=no,resizable=no,status=yes')&quot; & &quot;</SCRIPT>&quot;)
 
Actually, while the above code is a solution, the extra concatenation is unnecessary. The error in the original statement was the single quotes around the value of msg. Since this value is being passed as the value in the querystring there should be no quotes around it. The second part of this error is that the inner quotes around that value are causing a run-on string in the javascript:
Code:
Response.Write(&quot;<SCRIPT>window.open('error.asp?msg='&quot; & msg 
JS String Starts--------------------^
JS String Ends-------------------------------------^

& &quot;','ErrorPage','WIDTH=635,HEIGHT=400,scrollbars=no,resizable=no,status=yes')</SCRIPT>&quot;)
The reason it is complaining about the extra paran is because it has resolved parantheses before resolving string delimiters (quotes).

This means that to solve the problem it is only necessary to remove the single quotes around the querystring value, i.e., ASP variable msg.

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
 
Thanks,

Response.Write(&quot;<SCRIPT>window.open('error.asp?msg='&quot; & msg
JS String Starts--------------------^
JS String Ends-------------------------------------^

& &quot;','ErrorPage','WIDTH=635,HEIGHT=400,scrollbars=no,resizable=no,status=yes')</SCRIPT>&quot;)


What about the single quote in red bold here? & &quot;','ErrorPage','WIDTH....
regards,
Brian
 
Thats the ending quote after msg to, kill it

I didn't realize I only implied it was a bad 'un too until after I submitted, sorry :)

the finished line should look like this:
Response.Write(&quot;<SCRIPT>window.open('error.asp?msg=&quot; & msg & &quot;','ErrorPage','WIDTH=635,HEIGHT=400,scrollbars=no,resizable=no,status=yes')</SCRIPT>&quot;)

With no single quotes around the data you are inserting from the ASP variable.

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
 
thanks, I will give it a shot. regards,
Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top