Hi, I am completly new at jQuery (and javascript in general) and find my self struggling with this:
The amount of forms will vary from 0-50+ and is automatically generated through PHP. The forms are pretty much identical, except from they all have a hidden input field which contains a workout id.
Once the user hits submit, I want to call a php-function which retrieves all the data from the database and portrays the data in a table in a table/Div-overlay on top of the page. I can do the HTML and PHP myself, but I am struggling on how to do a jQuery submit eventlistener that will work on all forms and at the same time allow my to call the required PHP function with single id-required for the work that has been selected.
How do I through jQuery create an onClick event that tells me which form was selected and allows me to use the selected id in a PHP function. I have spend days googling this, but I don't know where to start. Tried formData, Serialize, Map.. everything I can find on google.
THE HTML FORM:
<form method="post" id="form_gotoW" class"Form_select_workout">
<input type="hidden" name="Planned_id" Value="1">
<input type="submit" value="Start work">
</form>
<form method="post" id="form_gotoW" class"Form_select_workout">
<input type="hidden" name="Planned_id" Value="2">
<input type="submit" value="Start work">
</form>
...
<form method="post" id="form_gotoW" class"Form_select_workout">
<input type="hidden" name="Planned_id" Value="9">
<input type="submit" value="Start work">
</form>
THE jQuery SO FAR, which is obviously not working:
$(document).ready(function() {
console.log("website is ready")
$("Form#form_gotoWt").submit(function() {
var currentThis = this;
alert($("form_gotoW#Planned_id").val());
event.preventDefault();
});
});