Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 624
  • Last Modified:

for loop in Macintosh Safari

hi folks,

I have a javascript that runs fine on firefox and IE.. no problems at all. But when I run it on safari, it looks like it takes forever or safari just hangs.. any idea how to make it work under safari as well? I'm pretty sure it is something to with the for loop because, if I reduce the number of records being pulled from the DB, the performance is better.. here is the code.. I have coldfusion query that pulls out atleast 6000 records from the DB..

The idea is that i have a text box and "name_search".. I type in something there and it will take me to the option in the 3 selec boxes to match the letters.. for eg. If I type in "S" it will take me to the option that begins with "S" in the 3 select boxes and so on..

here is the JS:

function fillin(){
            var str = document.frm.name_search.value;
            pattern = new RegExp("^"+str,"i");
            var sellength = document.frm.smart_brokerage.length;
            for(var i=0; i<sellength; i++){
                  if (pattern.test(document.frm.smart_brokerage.options[i].text)){
                        document.frm.smart_brokerage.options[i].selected = true;
                        //dsp_CSZ('smart',document.frm.smart_brokerage.options[i].value)
                        break;
                  }
            }
            
            sellength = document.frm.contract_carrier.length;
            for(var i=0; i<sellength; i++){
                  if (pattern.test(document.frm.contract_carrier.options[i].text)){
                        document.frm.contract_carrier.options[i].selected = true;
                        //dsp_CSZ('smart',document.frm.contract_carrier.options[i].value);
                        break;
                  }
            }            

            sellength = document.frm.cm_something.length;
            for(var i=0; i<sellength; i++){
                  if (pattern.test(document.frm.cm_something.options[i].text)){
                        document.frm.cm_something.options[i].selected = true;
                        //dsp_CSZ('cc',document.frm.cc_something.options[i].value);
                        break;
                  }
            }            
            
            
            
      }
0
adonis1976
Asked:
adonis1976
1 Solution
 
devicCommented:
Im not sure what is about sufari... try this:
========================================
function fillin()
{
      selectIt("smart_brokerage");
      selectIt("contract_carrier");
      selectIt("cm_something");               
}
function selectIt(nm)
{
      debugger;
      var el=document.frm.elements;
      var str = el["name_search"].value;
      pattern = new RegExp("^"+str,"i");
      for(var i=0; i<el[nm].length; i++)
      {
            if (pattern.test(el[nm].options[i].text))
            {
                  el[nm].options[i].selected = true;
                  return i;
            }
      }
}
0
 
adonis1976Author Commented:
it did the same, took forever.. i don't know what to do..
0
 
cookiejCommented:
It might be a problem with your tags in the form.  Safari is much more picky than IE when it comes to id & name tags and I think with capitalization.
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now