Google Answers Logo
View Question
 
Q: HTML Form Submit to new window ( Answered 5 out of 5 stars,   1 Comment )
Question  
Subject: HTML Form Submit to new window
Category: Computers > Internet
Asked by: felix-ga
List Price: $10.00
Posted: 05 Sep 2002 09:16 PDT
Expires: 05 Oct 2002 09:16 PDT
Question ID: 61943
I have a form on a standard HTML page which I need to submit and see
the results in a new window. I would like that new (pop up window) to
be centralised, a specific size and have no tool bar, address bar or
buttons, but with a status bar. I would also like the main page to
change to another .html page.

Is that possible and could you amend a page I have created to do so?
Please help me!

Thanks,

Stephen

Request for Question Clarification by websearcher-ga on 05 Sep 2002 09:53 PDT
Hi felix-ga:

Have you actually posted your attempt at this? It would really help to
be able to see where you're at.

Thanks. 

websearcher-ga
Answer  
Subject: Re: HTML Form Submit to new window
Answered By: joseleon-ga on 05 Sep 2002 12:25 PDT
Rated:5 out of 5 stars
 
Hello, felix:

  This was a really interesting question and maybe I will use it in my
own developments. I post the code I created using Dreamweaver, I have
tested it on Mozilla, IE, and Opera and it works like a charm. Let me
explain what this code does:

-It's a simple webpage, it contains a form with an input text and a
submit button
-When the form is submited the OnSubmit event is executed and...
-It calls the routine MM_openBrWindow to open a new window with all
the features you specified, only a status bar
-Also specifies width and height (640x480)
-The URL to open is a Google search using the value the user entered
into the text field
-After open the window, the main window is redirected to another URL,
in this sample to http://answers.google.com
-The window is centered on screen using this code:
------------------------------------
  var l=(screen.width-640) / 2;
  var t=(screen.height-480) / 2;  
  features+=',left='+l;
  features+=',top='+t; 
------------------------------------

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  var l=(screen.width-640) / 2;
  var t=(screen.height-480) / 2;  
  features+=',left='+l;
  features+=',top='+t; 
  neww=window.open(theURL,winName,features);
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2)
eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n);
return x;
}

function MM_getProp(objName,x) { //v3.0
  var obj = MM_findObj(objName);
  if (obj && (obj.style)) 
  {
  	return (obj.value);
   }
}
//-->
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action=""
onSubmit="MM_openBrWindow('://www.google.com/search?q='+MM_getProp('textfield','')+'&ie=UTF-8&oe=UTF-8&hl=en&lr=','newwindow','status=yes,width=640,height=480');MM_goToURL('parent','http://answers.google.com');return
document.MM_returnValue">
  <input type="text" name="textfield">
  <input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>


When copying and pasting, be aware of Google Answers word wrapping,
which may break some of the code and could cause to don't work
correctly.

I think this answers solves all the requeriments you posted, but in
any case, don't hesitate to request for a clarification, I will more
than happy to help you.

Best regards.

Request for Answer Clarification by felix-ga on 05 Sep 2002 16:48 PDT
Would you do me a huge favour and drop it onto the actual page for me please?

The page in question is at http://www.silvermead.net/broadband/register.html

The address to send the page back to is felix@indiependance.com

Thank you so much - if this works like I'm sure it will your a star!

Clarification of Answer by joseleon-ga on 06 Sep 2002 00:32 PDT
Hello:
I would like to do it, but your form is directed to 

https://register.vip.uk.com/online_registration/cgi-bin/register.cgi

I think is better you modify the cgi code to popup the results using
the code I posted, but if you really want I think I could do it by
using only javascript, but it could be a huge task because I have to
call the cgi with all the form parameters. Tell me what you decide.

Request for Answer Clarification by felix-ga on 06 Sep 2002 02:42 PDT
Unfortunately I don't have access to the scripts and they cannot be
changed so we would have to work it using JavaScript.

It would also be very nice indeed if the pop up window had 2 frames
(one as a header, and the main one for the results)

I'm happy to increase the value of the question if you wish as I do
realise there's a bit of work involved in doing this and really
appreciate your help. Just let me know what you think a reasonable
price is.

Clarification of Answer by joseleon-ga on 06 Sep 2002 04:44 PDT
Hello:
 I have sent the modified register.html page to your e-mail account,
this is how it works:
 
-When the form is submitted, I specify the target frame where will
throw the results of calling the action url
-This frame belongs to a newwindow created in the routine
MM_openBrWindow, after create the window, a frameset is written into
it to create a topFrame and a mainFrame. The topframe is redirected to
://www.google.com, change it with your own header.
-Also, when the form is submitted, the main page is directed to
://www.google.com with this sentence

MM_goToURL('parent','://www.google.com'); 

change it to the URL you want

I think this answers meets all your requeriments, make a backup of
your original register.html before update it. I have not registered
into the site, but submitting the form without data it popups the
window with an error page requesting the required data. Test it to see
if works well and request for any clarification if you want.

Respect increase the quantity of the answer, I'm not allowed to
specify a price, in Google Answers you specify the price and if a
researcher thinks the answer is worth the money, then answers it. So
you are free to increase to the quantity you think is fair for my
work, I will be happy with any increase you make.

Regards and I hope you use Google Answers again.
felix-ga rated this answer:5 out of 5 stars
Absolutely first class - the solution works perfectly and the help and
support was incredible. Thank you so much for all your help.

Comments  
Subject: Re: HTML Form Submit to new window
From: bluemc-ga on 05 Sep 2002 10:31 PDT
 
hey stephen. i put a couple pages together which do what you need to.
check http://www.midnightraid.com/felix/form.htm
um. if that's what you need, i'd be happy to adapt it to any pages you
have already built.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy