Jump to content


Photo

Change form action on the fly?


  • Please log in to reply
3 replies to this topic

#1 shiny_spoon

shiny_spoon
  • Members
  • PipPip
  • Member
  • 26 posts
  • LocationCanada

Posted 11 October 2006 - 01:13 PM

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

Basically something similar to:

onmouseover="this.classname='css'"

...but for action! :P

Thanks!

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 11 October 2006 - 01:54 PM

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'

#3 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 11 October 2006 - 02:00 PM

or, if you want to use a mouseover function like you're referencing, you can attach this to the element within the form:
onmouseover="this.form.action='post';"

You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#4 shiny_spoon

shiny_spoon
  • Members
  • PipPip
  • Member
  • 26 posts
  • LocationCanada

Posted 11 October 2006 - 02:18 PM

Thank you both very much! ;D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users