post form to new window; preserve original form action property

B

Bosconian

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.
 
P

Peter Michaux

Bosconian said:
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;}
 
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 said:
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 ... ! ?
 
B

Bosconian

Peter Michaux said:
Bosconian said:
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.
 
B

Bosconian

ASM said:
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 said:
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 ... ! ?

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top