how can you have the same form handle by javascript multiple times on the same page?
Posted
by DeChamp
on Stack Overflow
See other posts from Stack Overflow
or by DeChamp
Published on 2010-05-22T02:52:54Z
Indexed on
2010/05/22
3:00 UTC
Read the original article
Hit count: 205
I have a thumb gallery where I am using ajax/javascript to submit a form per image to report the image as broken seamlessly along with php. The form and script is templated so the script is in the header and then the form is printed multiple times on the same page with a hidden field with a different id for the value per thumb. So basically this is what i have.
javascript in header
just a quick idea of the forms i have. Just a quick idea not what I actually have.
image1 followed by the form
image2 followed by the form
So when you hit the button it basically submits all of the forms at the same time. I am sure it can be fixed with a (this) or something like that so it only submits a single form at a time. Let me know please.
$(function() {
$(".submit").click(function() {
var imgId = $("#imgId").val();
var dataString = 'imgId='+ imgId;
if(imgId==''){
$('.success').fadeOut(200).hide();
$('.error').fadeIn(200).show();
$('.error').fadeOut(200).hide();
}else{
$.ajax({
type: "POST",
url: "inc/brokenImgReport.php",
data: dataString,
success: function(){
});
$('.error').fadeOut(200).hide();
$('.success').fadeIn(200).show();
setTimeout(function() {
$('.success').fadeOut(200); }, 2000);
}
return false;
});
});
© Stack Overflow or respective owner