Need assistance with jquery, need an expert ;)

I am trying to figure out how to use jquery for something like the following, here is what I want the script to do, before the page loads (DOM) I want the script to look on the page if there is a table row(tr) with a table data (td) with only a single number 1, 2, 3, or 4 like below then it will click the button whose number corresponds!
so in the example below there is 4 buttons each with values 1, 2, 3, and 4! notice that in the first td there is only a single number in it “4”, so the script would have to click on the button which has the value of “4”:
is this possible to do using jquery?



[/php] any help would be greatly appreciated

Note that I am no expert… (suble apology to js-guys)

// check every row $('table tr').each(function() { // check every td in every row $(this).find('td').each(function() { // set tdValue to the value of the td, cast to integer var tdValue = parseInt($(this).html()); if (tdValue > 0 && tdValue < 10) { // find the input with the same value as the td and click it // note that as the code stands this will redirect the user $(this).parent().find('input[value='+tdValue+']').click(); } }); });


note that you need to uncomment the last line for it to actually click it, it’s just to show that you’re not magically redirected if you don’t run the click

man you rocked that one Thank you!! I am awesome with the php but javascript is my downfall!!! I will be studying jquery a ton now since I am highly interested in its uses!!! Jquery is just bad a**!! :smiley: Thank you bro for the help! heres a karma looking at you!!!

Sponsor our Newsletter | Privacy Policy | Terms of Service