Which parts of the form should be submitted based upon select
Hi everyone. I'm hoping someone can help me with how I should handle this problem.
I have a form that contains a select with multiple data elements for each option. The data elements are not consistent because what needs to be submitted along with where the form action should be will be different depending upon what the user selects.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.min.js"></script>
<form id="fbform" class="fbform" action="http://this-is-the-url-that-i-need-to-replace-depending-upon-a-select-option.com" method="POST">
<input type="text" name="firstname" id="firstname" placeholder="First name">
<input type="text" name="lastname" id="lastname" placeholder="Last name">
<input type="email" name="email" id="email" placeholder="Email address">
<input type="hidden" name="finadestination" id="finaldestination">
<input type="hidden" name="postmethod" id="postmethod">
<input type="hidden" name="spinner" id="spinner">
<select name="country" id="country">
<option value="" selected disabled >Select Your Country</option>
<option value="US"
data-id="http://www.destination-url.com/processing-page.php"
data-poster="POST"
data-unbalanced="round-and-round"
>United States</option>
<option value="AF"
data-id="http://www.a-different-url.com/a-different-processing-page.php"
data-poster="GET"
>Afghanistan</option>
</select>
<button type="submit" class="largebutton"><span>Submit Form</span></button>
<script type="text/javascript">
//* Determine some form specifics --> *//
$(document).ready(function ()
{$("#fbform").change(function ()
{
var destination = $("#country").find(':selected').data('id');
$("#finadestination").val(destination);
var postype = $("#country").find(':selected').data('poster');
$("#postmethod").val(postype);
var dizzy = $("#country").find(':selected').data('unbalanced');
$("#spinner").val(dizzy);
return true;
});
});
</script>
I'm just lost as to how I can send the form with a dynamic action, post type, and a unique data set depending upon the form selection.
I've tried a lot of different things and feel defeated. Any help appreciated very much.