Javascript 'check all'.... with a twist (help, please)

Discussion in 'Web Design and Development' started by Baron58, Jul 13, 2007.

  1. Baron58 macrumors 6502

    Joined:
    Feb 19, 2004
    #1
    OK, here's a tough one for you.

    There's a website where you can search for data on businesses meeting whatever criteria (say, Apple Stores in zip code 90210, for example). The results are returned on a web page in a long list, with a checkbox by each. You can download the results as a .csv file, but the catch is that you have to click the checkbox by each line that you want to download. That wouldn't be a big deal if there were simply a 'check all' button, but there isn't one...... so if a person is downloading thousands of records, that is thousands of checkboxes that have to be clicked one-by-one.

    There are plenty of examples of how to add a 'check all' button to a page (like http://javascript.internet.com/buttons/check-all.html), but obviously I have no control over how that website works. I just need to find a user-side solution.

    I know it's possible to execute javascript directly from the browser address bar, like this:
    Code:
    javascript:alert ('Hello, world!');

    I'm really hoping that there is a way to do this to let the user 'check all' of the thousands of records in one step. I tried this, but it didn't work (I know diddley about javascript, as you can see):
    Code:
    javascript:
    var checkflag = "false";
    function check(field) {
    if (checkflag == "false") {
    for (i = 0; i < field.length; i++) {
    field[i].checked = true;}
    checkflag = "true"; }
    }
    Can anyone help me make this happen?

    Thank you in advance.

    Edit: What made me think of it was this javascript trick - paste this in your browser address bar and hit 'enter':
    Code:
    javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.getElementsByTagName("img"); DIL=DI.length; function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=(Math.sin(R*x1+i*x2+x3)*x4+x5)+"px"; DIS.top=(Math.cos(R*y1+i*y2+y3)*y4+y5)+"px"}R++}setInterval('A()',5); void(0);
     
  2. CoreWeb macrumors 6502

    Joined:
    Mar 2, 2007
    Location:
    Edge of reason
    #2
    I couldn't help for sure without seeing the page. But here is something which should check all checkboxes on a page:

    Code:
    javascript:var inputs=document.getElementsByTagName('input');for (var i = 0; i<inputs.length; i++){if (inputs[i].type=='checkbox') inputs[i].setAttribute('checked','checked'); }
    Keep in mind though that this should check ALL checkboxes on the page, not just the area you want. This may or may not cause problems.
     
  3. angelneo macrumors 68000

    Joined:
    Jun 13, 2004
    Location:
    afk
    #3
    There's some firefox addon (if you are using it), that allows you to inject javascript code. I think it's called Greasemonkey.
     

Share This Page