I've got very little javascript programming skill, so this must be the problem with it. My problem is not so complicated, but I just can't find the answer for it, I tried nearly everything, but as I said, I'm lame in javascript programming.
My problem is, that I have got a php page, on this page there are multiple forms generated by mysql queries. I use them to post dynamiccally generated hidden field values to another php file and in that file I can use their post values without refreshing the main page. The form id's (or names) are also generated by the mysql queries. I use javascript to validate (?) a form and send it's hidden contents to the another page.
Javascript:
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#1").validate({
debug: false,
submitHandler: function(form) {
$.post('process_like_dislike.php', $("#1").serialize(), function(data) {
$('#results').html(data);
});
}
});
});
</script>
As you can see, the form id in this case is 1. I generate nearly 40 unique forms on one page, it depends on the mysql queries.
Php:
<form name='$formnumber' id='$formnumber' action='' method='POST'>
<input type=hidden value='$us_id' name='us_id' id='us_id'>
<input type=hidden value='$an_id' name='an_id' id='an_id'>
<input type=hidden value='1' name='on' id='on'>
<input type=submit class=something value='' title='Something'>
</form>
I don't know how should I make the javascript code to dynamically validate the chosen form on submit. I tried to get the php formnumber variable in the javascript, but that didn't help. I don't know if there is another way, but I only know this one. I need to pass the dynamically generated hidden values to another page, but I need a dynamically generated javascript for it, or I don't know.
The main concept of this code, that I made a page where you can rate a thing and that thing has got hidden values that I need to get in post format, because this is the only way that I can decide which button has been pressed to do the mysql query in the second php file without refreshing the current one. I don't want simple posts, because I would lose the previous page and I don't want to refresh the page.
Please help me out, thank you guys.