Go4Expert (http://www.go4expert.com/)
-   Web Design, HTML And CSS Forums (http://www.go4expert.com/forums/web-design-forum/)
-   -   Need help with Click() (http://www.go4expert.com/forums/help-click-t18095/)

w!ck3d 19Jun2009 02:27

Need help with Click()
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
//click button3

To click a button i use:

It works fine as long as i know the form name and the button name like clicking the search button in google would be:

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?

SaswatPadhi 19Jun2009 18:56

Re: Need help with Click()
You can loop through all forms on a document this way :

Code: JavaScript

var AllForms = document.forms;
var TForm;
for (i = 0; i < AllForms.length; ++i)
      TForm = document.forms[i];
      // To click a button

It depends on you to check which form you want : you can check properties of TForm before clicking button.

All times are GMT +5.5. The time now is 04:06.