Solved

jquery working in FF but not IE...

Posted on 2010-11-08
4
284 Views
Last Modified: 2012-05-10
Hello, I wrote this little piece of script.. but for the life of me I can't seem to figure out why and how it's now failing in IE but not FF.... this is the bit I think is the issue..


loadPastSearch();
$("select[name='Species'],input[name='breed'],select[name='Gender'],select[name='Pet_Friendly'],select[name='Child_Friendly'],input[name='Good_with_Children'],input[name='Good_with_Cats'],input[name='Good_with_Dogs'],input[name='Housetrained']").live('change',function() {                        
  var obj=$(this);
  pushSearch(obj);
  if(refinIt){refinment(obj);}
  alert('test');
});



but I pasted the whole lot below... now.. here is the twist.... it works in IE here..
http://www.petrescueville.com/index.php?page=home

but fails here
http://www.petrescueville.com/index.php?page=search 

I'm sure it's something simple.. any ideas? Thank you for the help.. Cheers -Jeremy

var searchin='';

  var string='';

  var total='';

  var rogue='';

  var oldVal=new Array();

  var refinIt=false;

function dump(arr,level) {

  var dumped_text = "";

  if(!level) level = 0;

  

  //The padding given at the beginning of the line.

  var level_padding = "";

  for(var j=0;j<level+1;j++) level_padding += "    ";

  

  if(typeof(arr) == 'object') { //Array/Hashes/Objects 

    for(var item in arr) {

      var value = arr[item];

      

      if(typeof(value) == 'object') { //If it is an array,

        dumped_text += level_padding + "'" + item + "' ...\n";

        dumped_text += dump(value,level+1);

      } else {

        dumped_text += level_padding + "'" + item + "' => \"" + value + "\"\n";

      }

    }

  } else { //Stings/Chars/Numbers etc.

    dumped_text = "===>"+arr+"<===("+typeof(arr)+")";

  }

  return dumped_text;

}



function pushSearch(obj){

  var newVal='';

  var Newsearchin='';

  var name=$(obj).attr('name').toString();

  if(!$(obj).is(':checkbox')){

    newVal=$(obj).val();

  }else{

    if ($(obj).is(':checked')){

      newVal=$(obj).val();

    }else{

      newVal='';

    }

  }

  var searchin=$("input[name$='search_text']").val();



  Newsearchin=searchin.replace(oldVal[name],'');



  oldVal[name]=newVal;

  Newsearchin=Newsearchin+' '+newVal;

  $("input[name$='search_text']").val($.trim(Newsearchin));



}

function refinment(obj){

  $('.contentMainInner').append('<img src="/uploads/siteTheme/loading.gif" class="loading"/> Loading ... ');

    $.post($(obj).closest("form").attr('action'),

      $(obj).closest("form").serialize()+"&"+$("input[name$='search_submit']").attr('name')+"="+$("input[name$='search_submit']").attr('name')+"&showtemplate=false",

      function(data){

      $('.contentMainInner').html(data);

      loadPastSearch();

    });  

}

function loadPastSearch(){

  if($('.search').length < 1){

    $("input:not('#retry input')[name$='search_text']").val('');

  }

  if($('.search').length > 0 && $('#lookingFor').length > 0 && $('#lookingFor').html()!=''){

    $("input[name$='search_text']").val($('#lookingFor').html());

    

    var pastSearch=$('#lookingFor').html();

    var lookingpostal=$('#lookingpostal').html();

    var lookingradius=$('#lookingradius').html();



    if(pastSearch.indexOf(" ") != -1){

      var str=pastSearch.split(" ");

    }else{

      var str=new Array();

      str.push(pastSearch);

    }

    //alert(dump(str));

    for (var i=0;i<str.length;i++){

      var found=false;          

      $('.search input').each(function(index, domEle) {

        if($(this).val()==str[i]){  

            var theName = str[i];

            oldVal[$(this).attr('name')]=str[i];

           // alert('.search input --'+str[i]);

            if(!$(this).is(':checkbox')){

              $(this).val(str[i]);

              found=false;

            }else if($(this).is(':checkbox')){

              $(this).attr('checked','checked');

              if( !$('.refine').is(':visible') ) { 

              $(".refine").toggle("slow");

              }

              if( !$('.refine:last').is(':visible') ) { 

              $(".refine").toggle("slow");

              }

              found=true;

            }

        }

      });  

      $('.search option').each(function(index, domEle) {

        //alert($(this).val()+' --'+str[i]);

        if($(this).val()==str[i]){  

            var theName = str[i];

            oldVal[$(this).closest('.search select').attr('name')]=str[i];

            //alert('.search select --'+str[i]);

            $(this).attr('selected','selected');

            found=true;

        }

      });

      //alert(dump(oldVal));

      if(found==false){

        rogue=rogue+' '+str[i];

      }  

    }

    //alert('final: '+dump(oldVal));

    $("input[name='breed']").val($.trim(rogue));

    $("input[name$='ccev_postal']").val(lookingpostal);

    $("input[name$='ccev_radius']").val(lookingradius);

    

    refinIt=true;

  } 

}





$(document).ready(function(){

loadPastSearch();

$("select[name='Species'],input[name='breed'],select[name='Gender'],select[name='Pet_Friendly'],select[name='Child_Friendly'],input[name='Good_with_Children'],input[name='Good_with_Cats'],input[name='Good_with_Dogs'],input[name='Housetrained']").live('change',function() {                        

  var obj=$(this);

  pushSearch(obj);

  if(refinIt){refinment(obj);}

  alert('test');

}); 

  

  

  

  $("input[name$='cal_search_submit']").live('click',function(event) {

    if($("select[name='Species']").val()==''){

      event.preventDefault();

      alert('Please choose a species');

    }

  });

  

  $('.Linkrefine').live('click',function (event) {

    event.preventDefault();

    $(this).next(".refine").toggle("slow");

  });  

  

});

Open in new window

0
Comment
Question by:jeremyBass26
  • 2
  • 2
4 Comments
 
LVL 13

Expert Comment

by:dsmile
ID: 34090160
I think you call the same script twice and it causes the problem

<script src="scripts/SpryMenuBar.js" type="text/javascript"></script>

<script type="text/javascript" src="http://www.petrescueville.com/uploads/lib/SD-temp/groupID/1.js?1289264665"></script> // <--- this line should be removed since it's called at the end of the page


0
 
LVL 4

Author Comment

by:jeremyBass26
ID: 34090335
nope.. nothing to do with it.. sorry... one is a menu script.. the other.. is the script above.. tk
0
 
LVL 13

Accepted Solution

by:
dsmile earned 500 total points
ID: 34090515
Try to move <script type="text/javascript" src="http://www.petrescueville.com/uploads/lib/SD-temp/groupID/1.js?xyz"></script>
to below <script type="text/javascript" src="http://www.petrescueville.com/uploads/lib/SD-temp/scriptID/1.js?xyz"></script>

I saved your search page to local and your script works again either when I remove that /groupID/1.js or move it to below /scriptID/1.js
0
 
LVL 4

Author Closing Comment

by:jeremyBass26
ID: 34093825
What you were asking to do doesn't work.. but.. there is something with colorbox that was getting in the way.. but I have a path to beat down.. thanks..
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jQuery Syntax 2 47
validation, if text area is typed or pasted into 2 25
Animated .jpg? 13 59
using php variable inside javascript 5 13
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now