Computing.Net > Forums > Web Development > Javascript - SN u wud be useful

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Javascript - SN u wud be useful

Reply to Message Icon

Name: Jamie_McCoy
Date: April 4, 2005 at 11:53:51 Pacific
OS: XP Pro 5.1
CPU/Ram: Pentium 4 2.4Ghz
Comment:

ok, heres what i need

you know the way you have a form, well when you click submit you can either have the form submit the details to new page in the same window, or to a new window using target=BLANK

well heres what i need

i want the form to submit to a new popup window, no file menu, address bar etc etc

how tho?

<form action=page.php target=(javascript:POPUP HERE)>

really need help on this 1


roamhosting.net



Sponsored Link
Ads by Google

Response Number 1
Name: Michael J (by mjdamato)
Date: April 4, 2005 at 14:56:36 Pacific
Reply:

Just create your form tag as you would normally with a target to the name you will create to the popup window. But instead of a SUBMIT button, create a generic button with an onClick action to a JS function. The function will first create the popup window with the same name you specified in the form target, then it will submit the form.

You can copy the following and save it as "theForm.htm" to see an example.

<html>

<head>
<script>
function submitForm() {
window.open ("theForm.htm", "NewWindow","menubar=0,resizable=1,width=350,height=250");
document.myform.submit();
}
</script>
</head>

<body>

<form action="theForm.htm" name="myform" target="NewWindow">
<input type=text name=name>
<input type=button onClick="javascript:submitForm();" value="submit">
</form>

</body>
</html>


0

Response Number 2
Name: Jamie_McCoy
Date: April 4, 2005 at 15:38:24 Pacific
Reply:

m8, u r da king!!!

exactly wot av bin after, thnks a lot

roamhosting.net


0

Response Number 3
Name: SN
Date: April 5, 2005 at 12:20:51 Pacific
Reply:

Very clever Michael - a lot cleaner than the way I was thinking of.

Jamie, just be aware that your page will be called twice, so make sure and check that there is POST data before doing anything.

-SN


0

Response Number 4
Name: Jamie_McCoy
Date: April 5, 2005 at 18:14:50 Pacific
Reply:

Why will it be called twice?

roamhosting.net


0

Response Number 5
Name: SN
Date: April 6, 2005 at 07:00:29 Pacific
Reply:

It will be called twice...Once on window.open, the next when the form is submitted. When the button is clicked, the javascript opens a new window with the name "NewWindow" that opens "theForm.htm" - with no POST data. Then, right after the window is opened and the request is made for "theForm.htm", the Form submit hijacks this window - cancelling the first request and re-requesting theForm.htm with all the POST data from the form.

It doesn't have to be submitted twice...You could have the javascript open a blank html file, then the form's action would be your PHP. This would probably be your best bet.

-SN


0

Related Posts

See More



Response Number 6
Name: Jamie_McCoy
Date: April 6, 2005 at 08:18:09 Pacific
Reply:

ahhh, so kind of like

target = newWindow

newWindo contains

<?
include("formstuff.htm");
?>

correct ?

roamhosting.net


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: Javascript - SN u wud be useful

FREE Chat for Site? www.computing.net/answers/webdevel/free-chat-for-site/1291.html

Open URLs in PHP w/out opening wind www.computing.net/answers/webdevel/open-urls-in-php-wout-opening-wind/199.html

Frame - Page Title www.computing.net/answers/webdevel/frame-page-title/215.html