glbscripts.myfreeforum.org Forum Index glbscripts.myfreeforum.org
Forum dedicated to Greasemonkey Scripts made for Goal Line Blitz online game.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   Join! (free) Join! (free)
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


coding help

 
Post new topic   Reply to topic    glbscripts.myfreeforum.org Forum Index -> Problems and Support
View previous topic :: View next topic  
Author Message
dudeamis
Developer


Joined: 08 Jul 2008
Posts: 13

PostPosted: Tue Jul 29, 2008 7:05 am    Post subject: coding help Reply with quote

hey guys and serenity, I'm trying to write a function that loops through a list of arrayed names, and for each name looks at a different array for specific information.

ie, (code not perfect)

var Name = new Array ("Tom", "Dick", "Harry");

var Pos1= new Array ("QB", "RB")
var Pos2= new Array ("RB,"FB")
var Pos3= new Array ("RB")

So basically I want a function that will go through the Name array, and for each name look at Pos1 for Name[1], Pos2 for Name[2], etc and then let the innerHTML of a div=the div's innerHTML + Name[x] + "<br>"; where x is the number of the name array where it found the position I was looking for.

so if I do a QB search it should look like:

Tom

and a RB search would look like:

Dick
Harry

thanks in advance.


Back to top
View user's profile Send private message
pabst
Developer


Joined: 23 Jun 2008
Posts: 235

PostPosted: Tue Jul 29, 2008 2:34 pm    Post subject: Reply with quote

Something like this should be close.  I can't do anything about getting the div until I know what page you're working with.

Code:

var Name = [];
var Pos = [];

function main() {
    addPlayer("Tom",["QB","RB"]);
    addPlayer("Dick",["RB","FB"]);
    addPlayer("Harry",["FB"]);
}

function addPlayer(name, positionArray) {
    var idx = Name.indexOf(name);
    if (idx == -1) {
        idx = Name.length;
        Name.push(name);
        Pos.push(positionArray);
    }
    else {
        Pos[idx] = positionArray;
    }
    return idx;
}

function searchPositions(p) {
    var result = [];
    for (var idx=0; idx<Pos.length; idx++) {
        if (Pos[idx].indexOf(p) != -1) {
            result.push(Name[idx]);
        }
    }
    return result;
}

Back to top
View user's profile Send private message
dudeamis
Developer


Joined: 08 Jul 2008
Posts: 13

PostPosted: Thu Jul 31, 2008 5:12 am    Post subject: Reply with quote

thanks!

okay something like this

<div>
<img src="QB.gif" onclick="ListTheQBs()">
</div>

<div>
<img src="RB.gif" onclick="ListTheRBs()">
</div>

<div id="PlayerByPositionList">
</div>

so that when I click on one of the gifs I get a list of players who have that position.
Back to top
View user's profile Send private message
mw54finest
Site Admin


Joined: 22 Jun 2008
Posts: 160

PostPosted: Thu Jul 31, 2008 8:18 am    Post subject: Reply with quote

lol at the names. Very Happy
_________________
Eat, Sleep, Live GLB!
Back to top
View user's profile Send private message
pabst
Developer


Joined: 23 Jun 2008
Posts: 235

PostPosted: Thu Jul 31, 2008 9:03 pm    Post subject: Reply with quote

For my table sorting, I do this stuff.  Not sure how it might help you if you're hard coding the HTML but it's here in case its useful.
Code:

//this code checks a row for the stat headings
className = sibling.getAttribute("class");
if (className.match("nonalternating_color2") != null) {
    //when it finds a stat heading, add a click event to it
    sibling.addEventListener("click",sortEvent,true);
    rows++;
}


The event handler is most likely what you'll need.  Not being an HTML guru, I'm not sure if the evt variable gets passed automatically the way your page is written (I would assume it does).
Code:

function sortEvent(evt) {
    //evt.target tells me which element was clicked
    //I need to use 2 parentNode references to go up the page to find what table it belongs to
    sortTable(evt.target.parentNode.parentNode,evt.target.cellIndex);
    return true;
}



Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    glbscripts.myfreeforum.org Forum Index -> Problems and Support All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Card File  Gallery  Forum Archive
Powered by phpBB © 2001, 2005 phpBB Group
Create your own free forum | Buy a domain to use with your forum