Forum Moderators: open

Message Too Old, No Replies

Open the form confirmation page in a pop up window

How to get that?

         

silverbytes

12:20 am on Apr 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The challenge: when pressing submit the confirmation page "ok" should open in a pop up window.
Easy huh?
Any code?

Rambo Tribble

3:43 am on Apr 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The script will also have to build the contents of the confirmation page, if I understand what you want done.

What does the confirmation page consist of?

cwebb

9:48 am on Apr 21, 2004 (gmt 0)

10+ Year Member



<script type="text/javascript">
function adopen()
{
window.open("popup.htm", "Name_of_popup_indow_doesntreallymatter" , "height=xx, width=yy", location=No,directories=No,status=No,menubar=No,scrollbars=No,toolbar=No)
}
</script>

does that help?

silverbytes

4:45 pm on Apr 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Easier than that Rambo Tribble,

an email field and an image button for submit.
once clicked a page telling "message sent ok" appears (but in a small pop up window) and auto closes in 3 secs.

I have that working using a native dreamweaver behaviour for the open pop up window (pasted in a external js file) and a form tag in my html with a reference to the js file in the head to import it.

It works but the problem is that an error appears when sending:

Line 51
Car 6
Error 'popupWindwow(...).document.body' null or not an object
Code 0
URL: myurl

the html code has this for the form:

<FORM id=newsletter name=newsletter
onsubmit="GP_AdvOpenWindow('formoknewsletter.php','ok',
'fullscreen=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no',400,135,'center',
'ignoreLink','',2,'');return document.MM_returnValue"
action=formoknewsletter.php method=post target=ok>

the rest is in the .js file

...

silverbytes

5:00 pm on Apr 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<script type="text/javascript">
function adopen()
{
window.open("popup.htm", "Name_of_popup_indow_doesntreallymatter" ,
"height=xx, width=yy", location=No,directories=No,status=No,menubar=No,scrollbars=No,toolbar=No)
}
</script>

I guess that's like the code similar to the behaviour script of dreamweaver...

I'm thinking if the error is because some duplicated data...

This is the .js file code: (first a validation, then the open window)

// JavaScript Document
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 ¦¦ p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange')!= -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min ¦¦ max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}

//-->
<!--
function GP_AdvOpenWindow(theURL,winName,features,popWidth,popHeight,winAlign,ignorelink,alwaysOnTop,autoCloseTime,borderless) { //v2.0
var leftPos=0,topPos=0,autoCloseTimeoutHandle, ontopIntervalHandle, w = 480, h = 340;
if (popWidth > 0) features += (features.length > 0? ',' : '') + 'width=' + popWidth;
if (popHeight > 0) features += (features.length > 0? ',' : '') + 'height=' + popHeight;
if (winAlign && winAlign!= "" && popWidth > 0 && popHeight > 0) {
if (document.all ¦¦ document.layers ¦¦ document.getElementById) {w = screen.availWidth; h = screen.availHeight;}
if (winAlign.indexOf("center")!= -1) {topPos = (h-popHeight)/2;leftPos = (w-popWidth)/2;}
if (winAlign.indexOf("bottom")!= -1) topPos = h-popHeight; if (winAlign.indexOf("right")!= -1) leftPos = w-popWidth;
if (winAlign.indexOf("left")!= -1) leftPos = 0; if (winAlign.indexOf("top")!= -1) topPos = 0;
features += (features.length > 0? ',' : '') + 'top=' + topPos+',left='+leftPos;}
if (document.all && borderless && borderless!= "" && features.indexOf("fullscreen")!= -1) features+=",fullscreen=1";
if (window["popupWindow"] == null) window["popupWindow"] = new Array();
var wp = popupWindow.length;
popupWindow[wp] = window.open(theURL,winName,features);
if (popupWindow[wp].opener == null) popupWindow[wp].opener = self;
if (document.all ¦¦ document.layers ¦¦ document.getElementById) {
if (borderless && borderless!= "")
{popupWindow[wp].resizeTo(popWidth,popHeight); popupWindow[wp].moveTo(leftPos, topPos);}
if (alwaysOnTop && alwaysOnTop!= "") {
ontopIntervalHandle = popupWindow[wp].setInterval("window.focus();", 50);
popupWindow[wp].document.body.onload = function() {window.setInterval("window.focus();", 50);}; }
if (autoCloseTime && autoCloseTime > 0) {
popupWindow[wp].document.body.onbeforeunload = function() {
if (autoCloseTimeoutHandle) window.clearInterval(autoCloseTimeoutHandle);
window.onbeforeunload = null;}
autoCloseTimeoutHandle = window.setTimeout("popupWindow["+wp+"].close()", autoCloseTime * 1000); }
window.onbeforeunload = function() {for (var i=0;i<popupWindow.length;i++) popupWindow[i].close();}; }
document.MM_returnValue = (ignorelink && ignorelink!= "")? false : true;
}
//-->

The html page code:
<SCRIPT language="JavaScript" SRC="js.js"></SCRIPT>
calls the js in the head and then

<form action="formoknewsletter.php" target="ok" method="post" name="newsletter" id="newsletter" onSubmit="GP_AdvOpenWindow('formoknewsletter.php','ok',
'fullscreen=no,toolbar=no,location=no,
status=no,menubar=no,scrollbars=no,resizable=no',400,135,'center','ignoreLink','',2,'');return document.MM_returnValue" >
<a name="suscribir"></a>
<table border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2">
<input type=hidden name="recipient" value="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#115;&#117;&#115;&#99;&#114;&#105;&#98;&#101;
&#64;&#107;&#105;&#108;&#108;&#101;&#114;&#115;&#105;&#116;&#101;&#115;&#46;&#99;&#111;&#109;&#46;
&#97;&#114;">
<input type=hidden name="subject" value="suscribe me">
<input type=hidden name="redirect" value="http://www.mysite/formoknewsletter.htm">
<span class="smallemphasis"> Suscribite al newsletter ahora!</span></td>
</tr>
<tr>
<td><span class="smallbold">E-mail:
<input name="email" type="text" class="field" onBlur="MM_validateForm('email','','RisEmail');return document.MM_returnValue" size="25">
<input name="okbot" type="image" id="okbot" src="img/okbot.gif" alt="Enviar" align="middle" width="20" height="14" border="0">
</span></td>
<td>&nbsp; </td>
</tr>
</table>
</form>

PS: Sorry for the long post... really.