I ve been trying to obtain the value of my form input elements, but I am just not having any luck with it.
I have the following form within a while loop in PHP, so there will be multiple forms.
<form method='POST' action=".$_SERVER['SCRIPT_NAME']." name='form_set_deadline' class='form_set_deadline'>
<input type='hidden' value='".$data3['unique_name']."' name='file_id' class='file_id' />
<input type='hidden' value='".$user_id."' name='client_id' class='client_id' />
<table>
<tr>
<td align='left'><input type='button' name='set_file_options' value='Submit' class='set_file_options' /></td>
</tr>
</table>
</form>
Now, I am trying to get the value of the hidden fields of jquery, but just don't know how to access the hidden field values. Remember, there are multiple of these forms on the page. Here is the jquery form, contained within a function.
function setFileOptions(){
$('.set_file_options').each(function(e){
$(this).unbind("click").click(function(e){
e.preventDefault();
//set form variables
var file_id = // DON'T KNOW HOW TO GET THE HIDDEN FIELD INPUT VALUE?
alert(file_id);
}); //END THIS CLICK FUNCTION
});
} //END MAIN FUNCTION
Thanks for the help/tips!
So after all the input received from you all, I have decided to use the following to get all the form data:
var form_data = $(this).closest('form').serialize();
Thanks again!