Jump to content

For Loop Issues


LogiQ121
 Share

Recommended Posts

I am trying to run this script as a bookmarklet in Firefox.The script is supposed to run through the every row's second cell of table 1 and compare it to the second cell of table 2. If there is a match, the script is supposed to check the 10th cell of the current row to check for "Non-Shipping". If it is a match then it will change the value of the textarea to show "Non-Shipping"+(The row number of table 1). If "Non-Shipping" is not present then it will move on to the next row of table 2. Once all the rows are finished, it goes back to Table 1 and does the same process again with the next row of table 1.My problem is that it will only find the match if the If the script is checking Table 1 row 1. If there is a no match for table 1 row 1 but there is a match for table 1 row 2 then it does not show it.Here is a link to the source of the page: http://erxz.com/pb/16084and here is the script I am running: http://erxz.com/pb/16083

Link to comment
Share on other sites

Does table 2 actually have 50 rows? The example you posted does not. If you're allowing x to increment, and rows[x] does not exist, the function will stop.
No it doesn't....so that is my issue then. Well then the amount of rows is dynamic so how would i specify to search all of them?
Link to comment
Share on other sites

Well then the amount of rows is dynamic so how would i specify to search all of them?
If you have any array of objects called "rows", then you can get the length of that array (i.e. the number of elements in the array) by doing "rows.length".To loop through all the objects in an array called "rows":
for(var i = 0; i < rows.length; i++){	// do something with rows[i];}

Link to comment
Share on other sites

Now that I have that working I have another issue I am trying to resolve. I am trying to loop through all the rows on the table below. With each loop I want to return the following information:Current row numberValue of cell[9] (ACTIVE or INACTIVE)The returned information has to be displayed in a text area which is lower on the page (not pictureed) For the table below it should look like this:1INACTIVE2ACTIVE3INACTIVE4ACTIVEHere is the link to the HTML table source:http://erxz.com/pb/16114.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...