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

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

    Multiple forms jquery


    Hi I have random number of forms in my page.

    I submit them on events like this:
    Code:
    function hotels()
    	{
    		$.post('reloads/results.php', { city: document.form.city.value},function(output){$('#hotels').html(output).show('slow');});
    	}
    I somehow need to add the form id to the function so I can submit any of the forms that I need. How can I chenage the code to something like this that works:
    Code:
    function hotels(form_id_200)
    	{
    		$.post('reloads/results.php', { city: document.form_id_200.city.value},function(output){$('#update_form_id_200').html(output).show('slow');});
    	}
    Thanks
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,958
    Rep Power
    9397
  4. #3
  5. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,650
    Rep Power
    171
    Thank you it is working! Hopefully this is a valid source.

    Originally Posted by requinix
    How are you calling that function?
    Code:
    onclick="check_paypal('form_<?php echo $data['PID'];?>')"
    Code:
    function check_paypal(formName)
    	{
    		alert(document.forms[formName].elements["firstname"].value);
    	}
    Last edited by zxcvbnm; July 21st, 2013 at 11:14 PM.

IMN logo majestic logo threadwatch logo seochat tools logo