SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Resistance is Futile webgodjj's Avatar
    Join Date
    Nov 2002
    Location
    Madison, WI USA
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    change part of a url post method with value from select box

    Hi,

    For a very specific project, I need to change the url of the post method for a form depending on the value of a select box.

    ie...
    Code:
    $('#email').change(function(){
    change the value of the email in the action of the form
    }
    HTML Code:
    <form method="post" action="index.asp?email=user@email.com&password=password">
    <select id="email" name="email">
    	<option value="">Please select a user</option>
    	<option value="user1@email.com">user1@email.com</option>
    	<option value="user2@email.com">user1@email.com</option>
    </select
    
    </form>

  2. #2
    SitePoint Evangelist TommiChi's Avatar
    Join Date
    Oct 2008
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your script would look something like this:
    $('#email').change(function() {
    $($('form')[0]).attr('action', 'index.asp?email='+ $(this).val());
    });

    I think this should work (I tend to write pure JS, so sometimes my brain goes a bit sideways for jQuery stuff....)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •