Jump to content

Archived

This topic is now archived and is closed to further replies.

shiny_spoon

Change form action on the fly?

Recommended Posts

Is it possible to change the action="" property of a form on the fly using JavaScript?

Basically something similar to:

[code]onmouseover="this.classname='css'"[/code]

...but for action! :P

Thanks!

Share this post


Link to post
Share on other sites
Yes. Give your form a name by adding the name="my_form_name" attribute to the form tag then use use the following javascript:

document.my_form_name.action='new action here'

Share this post


Link to post
Share on other sites
or, if you want to use a mouseover function like you're referencing, you can attach this to the element within the form:
[code]
onmouseover="this.form.action='post';"
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.