Jump to content

Need help with Click()

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
w!ck3d

w!ck3d

    Newbie

  • Members
  • Pip
  • 5 posts
I'm new to JS and i'm trying to write a script that will do something like this:

If on page #1
//click button1
else if on page#2
//click button2
else
//click button3

To click a button i use:
document.Form_Name.Button_Name.click();

It works fine as long as i know the form name and the button name like clicking the search button in google would be:
document.f.btnG.click();

But some forms don't have a name. All they have is something like:
<form action="Link" method="post" onsubmit="this.submit.disabled=true;">
.
.
.
and the button is:
<input name="submit" type="submit" onload="this.disabled=false;" value="OK">


How can i click such a button?

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Without seeing sample code that illustrates your problem, it will be very hard to help you.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
NatalieM

NatalieM

    Learning Programmer

  • Members
  • PipPipPip
  • 77 posts
Could you access them via the DOM tree, eg do their have a parent element or sibling with an ID and then you could get them via childNodes or nextSibling/previousSibling?