Jump to content

Issue with form submitting multiple times.


wwfc_barmy_army

Recommended Posts

Hi, Hoping someone can help. First off, i'm still reasonably new to Jquery but  i'm picking it up slowly. Basically i'm adding a search function to my site and I have this Jquery code:

 

$(document).ready(function()
{
//Display Loading Image
function Display_Load()
{
$("#loading").fadeIn(900,0);
$("#loading").html("<img src='images/bigLoader.gif' />");
}
//Hide Loading Image
function Hide_Load()
{
$("#loading").fadeOut('slow');
};

$("#pagination li:first")
.css({'color' : '#FF0084'}).css({'border' : 'none'});

$("#searchsubmit").submit(function(){  

var searchquery = document.getElementById("searchbox").value;
var searchtype = $('input[name=searchtype]:checked').val();
$("#pagination").load("includes/searchpag.php?search=" + searchquery);


Display_Load();

$("#thumbarea").load("includes/searchfunction.php?page=1&type=" + searchtype + "&search=" + searchquery, Hide_Load());
//$("#searchsubmit").fadeOut('slow');
      return false;  
  
});  


//Pagination Click
$("#pagination li").click(function(){
Display_Load();
//CSS Styles
$("#pagination li")
.css({'border' : 'solid #dddddd 1px'})
.css({'color' : '#0063DC'});

$(this)
.css({'color' : '#FF0084'})
.css({'border' : 'none'});

//Loading Data
var pageNum = this.id;
var searchquery = document.getElementById("searchbox").value
var searchtype = $('input[name=searchtype]:checked').val();

//	if(typeof cat != "undefined") { //if cat DOES exist

$("#thumbarea").load("includes/searchfunction.php?page=" + pageNum + "&type=" + searchtype + "&search=" + searchquery, Hide_Load()); 
      return false;  

});


});

 

It works fine and this is what shows in firebug:

http://yfrog.com/jamogsearchissue1j

 

But if i search for the same or another word with the results still there it seems to submit it a number of times, this is what shows in firebug after click it one more time (top 4 results were the original):

http://yfrog.com/0wmogsearchissue2j

 

I've spent hours trying to figure this out but I just can't seem to solve it.

 

Can anyone help?

 

Thanks.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.