By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,353 Members | 1,277 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,353 IT Pros & Developers. It's quick & easy.

post form to new window; preserve original form action property

P: n/a
I have created a form tool page that consists of several dropdowns which
allows a user to drill down and select a desired document for viewing in an
external window. I need to post the form data to the external window so the
values can be used to retrieve the appropriate document.

The function below will open the window and post the form data accordingly,
but when defining the action property it changes the original form action
property. I need to preserve the original form action property so the user
can switch back to the form tool window and retrieve additional documents.

What's the method for preserving the original form action property?

Thanks in advance.

-------------------------------------------

function newWindow() {
var newForm = document.forms[0];
window.open('newpage.php','newtarget','resizable=y es,scrollbars=yes,width=800,height=600'); newForm .target = 'newtarget'; newForm .method = 'post'; newForm .action = 'newpage.php'; return true;}

Dec 3 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Bosconian wrote:
I have created a form tool page that consists of several dropdowns which
allows a user to drill down and select a desired document for viewing in an
external window. I need to post the form data to the external window so the
values can be used to retrieve the appropriate document.

The function below will open the window and post the form data accordingly,
I don't see newForm.submit() in this function so the submission happens
somewhere else? Are you calling newWindow() from the onsubmit attribute
of the form element or from the onchange attribute of the select
element? Can you post a 30 line complete page that shows the form and
this newWindow function and how the two interact?

but when defining the action property it changes the original form action
property. I need to preserve the original form action property so the user
can switch back to the form tool window and retrieve additional documents.
After you submit the form you could reset the action to the original
which you either just know or you can store before you make the first
change.

-------------------------------------------

function newWindow() {
var newForm = document.forms[0];
window.open('newpage.php','newtarget','resizable=y es,scrollbars=yes,width=800,height=600'); newForm .target = 'newtarget'; newForm .method = 'post'; newForm .action = 'newpage.php'; return true;}
Dec 3 '06 #2

P: n/a
ASM
Bosconian a écrit :
I have created a form tool page that consists of several dropdowns which
allows a user to drill down and select a desired document for viewing in an
external window. I need to post the form data to the external window so the
values can be used to retrieve the appropriate document.
it is quite simple

<form action="searchDatas.php" target="viewer" method="get"
onsubmit="return displayDoc();">

function displayDoc() {
var f = document.forms[0];
if(f.doc.checked) {
var attr = 'resizable=yes,scrollbars=yes,width=800,height=600 '
f.target = 'viewer';
if(typeof(newDoc)=='undefined' || !newDoc || newDoc.closed)
newDoc = window.open('','viewer',attr);
newDoc.focus();
return true;
}
f.target = '_self';
return true;
}

In your form in your main mother window
you put a checkbox to allow popup or not

Doc in a popup <input type=checkbox name="doc" checked>
function newWindow() {
var newForm = document.forms[0];
window.open('newpage.php','newtarget','resizable=y es,scrollbars=yes,width=800,height=600'); newForm .target = 'newtarget'; newForm .method = 'post'; newForm .action = 'newpage.php'; return true;}
there is nothing here to change action of your form ... ! ?
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Dec 3 '06 #3

P: n/a
"Peter Michaux" <pe**********@gmail.comwrote in message
news:11**********************@j72g2000cwa.googlegr oups.com...
Bosconian wrote:
>I have created a form tool page that consists of several dropdowns which
allows a user to drill down and select a desired document for viewing in
an
external window. I need to post the form data to the external window so
the
values can be used to retrieve the appropriate document.

The function below will open the window and post the form data
accordingly,

I don't see newForm.submit() in this function so the submission happens
somewhere else? Are you calling newWindow() from the onsubmit attribute
of the form element or from the onchange attribute of the select
element? Can you post a 30 line complete page that shows the form and
this newWindow function and how the two interact?

>but when defining the action property it changes the original form action
property. I need to preserve the original form action property so the
user
can switch back to the form tool window and retrieve additional
documents.

After you submit the form you could reset the action to the original
which you either just know or you can store before you make the first
change.

>-------------------------------------------

function newWindow() {
var newForm = document.forms[0];

window.open('newpage.php','newtarget','resizable= yes,scrollbars=yes,width=800,height=600');
newForm .target = 'newtarget'; newForm .method = 'post'; newForm .action
= 'newpage.php'; return true;}
Ok, I got things sorted. I took your suggestion and restored the original
action property value after submission (which was mistakenly omitted from my
original message.) I'm also resetting the target property to '_self'.

Thanks for your reply.
Dec 3 '06 #4

P: n/a
"ASM" <st*********************@wanadoo.fr.invalidwrote in message
news:45***********************@news.orange.fr...
Bosconian a écrit :
>I have created a form tool page that consists of several dropdowns which
allows a user to drill down and select a desired document for viewing in
an external window. I need to post the form data to the external window
so the values can be used to retrieve the appropriate document.

it is quite simple

<form action="searchDatas.php" target="viewer" method="get"
onsubmit="return displayDoc();">

function displayDoc() {
var f = document.forms[0];
if(f.doc.checked) {
var attr = 'resizable=yes,scrollbars=yes,width=800,height=600 '
f.target = 'viewer';
if(typeof(newDoc)=='undefined' || !newDoc || newDoc.closed)
newDoc = window.open('','viewer',attr);
newDoc.focus();
return true;
}
f.target = '_self';
return true;
}

In your form in your main mother window
you put a checkbox to allow popup or not

Doc in a popup <input type=checkbox name="doc" checked>
>function newWindow() {
var newForm = document.forms[0];

window.open('newpage.php','newtarget','resizable= yes,scrollbars=yes,width=800,height=600');
newForm .target = 'newtarget'; newForm .method = 'post'; newForm .action
= 'newpage.php'; return true;}

there is nothing here to change action of your form ... ! ?
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Thanks for your reply.

Your function was instructive and helped me sort out the requirements for my
app. The action property must be redefined so that it points to the new
window only after the last selection. The original action property is then
restored so that the original form page will continue to work correctly.
Dec 3 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.