#1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,689
    Rep Power
    171

    Change form action on click


    Hi;

    Why doesn;t this work?
    html Code:
    <span onclick="change_action_to_results();">Submit</span>

    javascript Code:
    function change_action_to_results()
    		{
    			$('#form').attr('action', 'results.php');	
    		}
    Thanks
  2. #2
  3. Jealous Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,304
    Rep Power
    9400
    You've been here for a long time. Should have been long enough to know that "why doesn't this work" is not helpful to us.

    Maybe it's just midnight but that seems like it would work... provided there's other stuff going on and other stuff not going on. Post the rest of it.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    101
    Rep Power
    27
    Maybe it does work, you're just not submitting the form in your click handler. You'd need to $("#form").submit(); to do that.

    This jsfiddle: http://jsfiddle.net/m3Dq4/ shows an example

IMN logo majestic logo threadwatch logo seochat tools logo