Here is a complete example which shows how to
1. Open Pop Window.
2. Assign an action and target for a form
3. Submit the form.
Hope this helps you.
<html>
<head>
<title>
</title>
<body>
<script language="javascript">
var sw;
function OpenCenWindow (url, winname, width, height) {
var x = 0.5 *(window.screen.width - width);
var y = 0.5 *(window.screen.height - height);
var posStr = ", screenX=" + x + ", screenY=" + y;
if (document.all) {
posStr = ", left=" + x + ", top=" + y;
}
var pStr = 'resizable, status=no,width=' + width + ', height=' + height +
', alwaysRaised=1, toolbar=no, menubar=no, status=no';
var sw = window.open (url, winname, pStr+posStr);
return sw;
}
function SubmitForm(theForm, page) {
var w= OpenCenWindow("","targetwi
theForm.target = "targetWin";
theForm.action = theForm.action + Page ;
theForm.submit();
return false;
}
</script>
<form action="formSubmit.php" onsubmit="return SubmitForm(this, '?option=1');">
<input type="text" name="name">
<input type="submit" value="Submit Form">
</form>
</body>
</html>
Main Topics
Browse All Topics





by: German_RummPosted on 2007-03-02 at 03:12:19ID: 18639423
Easiest way is without Javascript at all, just use target attribute of a <form> tag
rm.target = "_blank"
<form target="_blank"...
Of course you can do it dynamically, like this:
document.forms.JobSearchFo
You can set target to anything, _blank is a special word that means open a new window.
If you already have opened window (with window.open, for example), you can set target attribute to the name of that window - and the form will submit into this window.