views:

42

answers:

1

I need either a javascript which can click on a button. The thing is, there are 100+ buttons on the page all with the same value. The name is unique but quite long.
The full name of the element is something like :

actions[http://apps.facebook.com/frontierville/giftaccept.php?next=giftaccept.php&senderId=1%3A1325206719&gh=3a8bfdace76051752a9127d1f9b43872&gift=nails&timestamp=1285598414&ref=tab&key=29b15e06ed9d7c00a8870c955ab938cf%24%24cfH1PUUZ%217bZYhg8M-o-XQc%218HHRMcvvyhuf4d%21.64qEvlQe&src=request&aff=gift&crt=nails&signature=6dd3fa03fe88f98b6dcab4faf4c7da94]

The value of every button is Accept and Play.

So. Is there a way to have it click on the button with a specific URL in the name?

I tried this:

javascript:(function(){var b=document.getElementsByName('actions[http://apps.facebook.com/frontierville/giftaccept.php?next=giftaccept.php&amp;amp;senderId=1%3A1325206719&amp;amp;gh=3a8bfdace76051752a9127d1f9b43872&amp;amp;gift=nails&amp;amp;timestamp=1285598414&amp;amp;ref=tab&amp;amp;key=29b15e06ed9d7c00a8870c955ab938cf%24%24cfH1PUUZ%217bZYhg8M-o-XQc%218HHRMcvvyhuf4d%21.64qEvlQe&amp;amp;src=request&amp;amp;aff=gift&amp;amp;crt=nails&amp;amp;signature=6dd3fa03fe88f98b6dcab4faf4c7da94]');for(var j=0;j<b.length;j++){if(b[j].value.match(/^Accept and Play/i)){b[j].click();break;}}})()

and it did not work. Any suggestions?

EDIT: If it helps, here is the source of the info for one of the buttons:

<input value="Accept and Play" type="submit" name="actions[http://apps.facebook.com/onthefarm/giftaccept.php?senderId=1259413693&amp;amp;gift=mysterygift&amp;amp;timestamp=1285599906&amp;amp;ref=gift_accept_tab&amp;amp;key=78fcc7de3b36b8f9564262fab506893f%24%24ceK5RVRY61bZYhg8M-o-XQcyL%2CzHccEwEeuj4e-%21-dh0AD0A2AgyScd&amp;amp;signature=32db959ce43f8330cf8fd992fbd53a51&amp;amp;srcapp=FarmVille]"&gt;
A: 

Hi,

your script works for me.

Are u sure, that you use the exact name in your script?

Are there other elements in the page, that share the same name? If it does: you better also check the type of these elements. If they are not click()-able Elements(for example hidden-Inputs or text-inputs, this will cause an exception, so your loop will be stopped)

Dr.Molle
Yeah there should be no other elements with the exact same name. As far as I know it is click()-able. They are not hidden or inputs or anything. When doing this manually I have to click them to submit.
Seatbelt99
Did you check, if b.length is greater than zero?
Dr.Molle
I'm not great with javascript. I'm mostly using other people's stuff and editing it. I'm trying to pick up on the concepts of how to do things as well but its slow going. I'm not sure if it is ok to do this so if not, please delete, but if someone could get on AIM and help me with this I can give them $5 (paypal) if we can get it working. My AIM is ChairRestraint66. Thanks!
Seatbelt99