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 do I submit from a submit button a pop-up window? 1

Status
Not open for further replies.

JrClown

Technical User
Oct 18, 2000
393
US
I now have this link (text) when clicked displaying a small 450x280 window. I want to user the same code with a submit buttton but now sure how to do it.

Here's what I've got.
1. User opens a log in page.
2. If name is not in my Access DB it redirects to an error.asp. I would like the error.asp to display in the small window below. HOW? Thanks

<p align=&quot;center&quot;>
<a href=&quot;#&quot; OnClick=&quot;window.open('toc.asp','newwindow','toolbar=no,directories=no,status=no, scrollbar=yes, width=450,height=280')&quot;><font color=&quot;#FF0000&quot; size=&quot;3&quot;></font><font color=&quot;#0000FF&quot; size=&quot;3&quot;>
</font><font color=&quot;#FF0000&quot; size=&quot;3&quot;> to Search</font></a>
</p>
&quot;The reward of one duty done is the power to fulfill another&quot;
<%
Jr Clown
%>
 
howabout this:
<%
if not in accessdb then<--- pseudocode
%>
<script language=javascript>
window.open('error.asp', 'errorWindow', 'toolbar=no,directories=no,status=no, scrollbar=yes, width=450,height=280')
</script>
<%
end if
%>

so that the javascript isn't in a function, but rather is written out inline if the user doesn't exist, popping up the new window, error.asp

and as far as wanting to make that text above a button, rather than a link, you can just put all that javascript in the onClick action for an input type of 'button' like:

<input type=button value=&quot;To Search&quot; onClick=&quot;window.open('toc.asp','newwindow','toolbar=no,directories=no,status=no, scrollbar=yes, width=450,height=280');&quot;>

hope it helps! :)
Paul Prewett
 
I'm having a problem because the page that checks for the log in name, actually does the redirect

like this:
I don't see why is not working.
<%Response.Buffer = True

requsername = request.form(&quot;username&quot;)
session(&quot;username&quot;) = request.form(&quot;username&quot;)

sql = &quot;SELECT ID, dept FROM logins WHERE username = '&quot; & requsername & &quot;'&quot;

Dim Count
set Count=server.createobject(&quot;adodb.recordset&quot;)
Count.open sql, &quot;dsn=matte&quot;

if Count.eof then
response.redirect = &quot; window.open('error.asp','newwindow','toolbar=no,directories=no,status=no, scrollbar=yes, width=450,height=280')&quot;
elseif Count(&quot;dept&quot;) = 1 then
SESSION(&quot;LOGIN_ID&quot;) = COUNT(&quot;ID&quot;)
response.redirect &quot;arlinks.asp&quot;
elseif count(&quot;dept&quot;) = 2 then
SESSION(&quot;LOGIN_ID&quot;) = COUNT(&quot;ID&quot;)
response.redirect &quot;verify2.asp&quot;
else
response.redirect &quot;error.asp&quot;
end if
%>
&quot;The reward of one duty done is the power to fulfill another&quot;
<%
Jr Clown
%>
 
make this:

if Count.eof then
response.redirect = &quot; window.open('error.asp','newwindow','toolbar=no,directories=no,status=no, scrollbar=yes, width=450,height=280')&quot;

into this:

if (Count.eof and Count.bof) then%>
<script language=javascript>
window.open('error.asp','newwindow','toolbar=no,directories=no,status=no, scrollbar=yes, width=450,height=280')&quot;
</script>
<%
elseif....


that will write the script to the screen -- the problem is you are putting client side javascript inside your server tags up there -- it just won't work

My question is, though -- what happens to the original page if the user doesn't exist??? Why not just open the error.asp in that page??

Not that I'm disagreeing, I'm just curious. If you do get a hit on that empty recordset, then a new window is going to open... and then what for the original??

:)
paul
 
right now when the logged name is not found, I simply display the error.asp page as the main page and asking users to click back or a link to go back.

My original Idea was to display the log in page and if the name was not found I would display the error.asp page ontop as a pop-up whith a close() &quot;close window&quot; on it, But the log in window would stay there. But I'm now thinking that's not possible and should just leave it the way it is. &quot;The reward of one duty done is the power to fulfill another&quot;
<%
Jr Clown
%>
 
. &quot;The reward of one duty done is the power to fulfill another&quot;
<%
Jr Clown
%>
 
No, no. Anything's possible. ;-)

Here's how you could handle it...

Let's talk it out, and then we'll code a bit.

User enters their information and hits login --
Page flips to new asp page, which checks to see if their information is there --
If it is there, then you do what you have to do --
If it isn't there, you first write out the client side script to popup the window, and then redirect them back to the login page --

Yes?

Here:

if (Count.eof and Count.bof) then%>
<script language=javascript>
window.open('error.asp','newwindow','toolbar=no,directories=no,status=no, scrollbar=yes, width=450,height=280')&quot;
</script>
response.redirect(&quot;loginPage.htm&quot;)
<%
elseif....


I think that would work just fine -- and I like the idea, too. :)

paul
 
I'll try it first thing Monday morning bro, thanks &quot;The reward of one duty done is the power to fulfill another&quot;
<%
Jr Clown
%>
 
It's working to the point of redirecting back to the log in page if the name is not found., But it's not displaying the error page. Here's the code bro

If (Count.eof and Count.bof) then%>
<script language=javascript>
window.open('error.asp','newwindow','toolbar=no,directories=no,status=no, scrollbar=yes, width=450,height=280')&quot;
</script>
<%
response.redirect &quot;default.asp&quot;
elseif Count(&quot;dept&quot;) = 1 then
SESSION(&quot;LOGIN_ID&quot;) = COUNT(&quot;ID&quot;)
response.redirect &quot;arlinks.asp&quot;
elseif count(&quot;dept&quot;) = 2 then
SESSION(&quot;LOGIN_ID&quot;) = COUNT(&quot;ID&quot;)
response.redirect &quot;verify2.asp&quot;
else
response.redirect &quot;error.asp&quot;
end if &quot;The reward of one duty done is the power to fulfill another&quot;
<%
Jr Clown
%>
 
Yea, I'm getting the same thing --

I think the problem is that the server side code is being interpreted in its entirety before the client side code --

try this:

redirect to this address:
default.asp?login=error

and then on the default page, have a little routine up top that would check the querystring for a value -- if it's equal to &quot;error&quot;, then popup the page, and if it's empty, then no harm, no foul.

That should work nicely.

:)
 
I decided not to mess with the way I originally thought about it, just displaying my error page as my main window. Thanks Paul &quot;The reward of one duty done is the power to fulfill another&quot;
<%
Jr Clown
%>
 
Oh, but wait!

vasah20 posted to another thread this solution for changing the location of your parent window from the child window. I can't believe I didn't think of that!

parent.location = 'default.asp';

or

window.opener.location = 'default.asp';

javascript, obviously --

 
Sure, I'll try it and let you know. Thanks again &quot;The reward of one duty done is the power to fulfill another&quot;
<%
Jr Clown
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top