Change form action then back again

M

mikew01

Hi all I am trying to write a function that changes a forms action on
the fly, submits the form then changes the action back again.
The reason I need to do this is because the forms primary action when
the submit button is pressed is to pass control back to the client
page that created the new page but I have added a drop down widget to
the page that when changed needs to re-submit the current page.
Heres the function, it works to a certain degree in that it changes
the action the first time and the current page is submitted but the
final statement to set the action back to the original uri does not
seem to work, the action stays set to the first assignment so when the
submit button is pressed the page just submits itself again?

function submitform( loadaction, formname, originalaction )
{
document.getElementsByName( formname )[0].action = loadaction;
document.getElementsByName( formname )[0].submit();
document.getElementsByName( formname )[0].action = originalaction;
}

Any idas why the final statement doesn't seem to work?

TIA

Mike.
 
T

Thomas 'PointedEars' Lahn

mikew01 said:
Hi all I am trying to write a function that changes a forms action on
the fly, submits the form then changes the action back again.

Can't be done.
The reason I need to do this is because the forms primary action when
the submit button is pressed is to pass control back to the client
page that created the new page but I have added a drop down widget to
the page that when changed needs to re-submit the current page.

You need to design that out of the application, for conforming to
accessibility guidelines and legislation alone. Use the same `action'
attribute value and different names and/or values for your submit buttons.
Avoid "submit" or other built-in properties of form objects for the name of
your submit buttons, though.
[...]
function submitform( loadaction, formname, originalaction )
{
document.getElementsByName( formname )[0].action = loadaction;
document.getElementsByName( formname )[0].submit();
document.getElementsByName( formname )[0].action = originalaction;
}

Any idas why the final statement doesn't seem to work?

As soon as the form is submitted with the same view as response display
target (and the server does not respond with a 204 No Content status code),
objects defined in the context of that view are being destructed. It is
reasonable to assume that document-related objects like element objects are
being destructed first because navigation took place and they are no longer
needed.


PointedEars
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top