PDA

View Full Version : Simulating a Button Click w/JavaScript


SilkMcNasty
08-20-2002, 03:52 PM
I have a form that I want to Auto-Save after 15 mins. I have a Save Button on my page that I want to trigger programatically with JavaScript

Any help or examples would be appreciated.

territoryOK
08-20-2002, 04:44 PM
Dude, you have a button named save or somthing like that,... that calls a function that saves the info from the form when pressed right? If thats the case then create a time loop that will call the save function every 15 minutes. If you have a submit button that sends the data to a DB to be saved every 15 minutes. Use a regular button and have a function that sends the info to the DB and then create a time loop that will call that function every 15 miutes. I don't know, just throwing some ideas your way.

Jon Hanlon
08-20-2002, 06:42 PM
IE has a click() method that you can invoke:
buttonObject.click()
But how did the Save Page button get there in the first place? Perhaps you could post a snippet of your code, with the bit that defines the Save button.

SilkMcNasty
08-21-2002, 09:01 AM
When you say 'buttonObject'. That that reference the NAME property of the button?

I triied that yesterday, but it didn't invoke the click. I have data going to the DB, via the Form-Post, and a JS function. If it was just the JS, I would just call the function, but I need to Post the form as well.

But by definition, the Click() method should do it.

Let me know your thoughts

Dr. Web
08-21-2002, 01:54 PM
why not just set a timer to auto submit the form?


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
<script language="javascript">
var TimerNew = setTimeout('document.it.submit()', 3000);
</script>
</head>

<body>
<form name=it action="http://www.yahoo.com" method=post>
<input type=text name=search value="titan">
</form>


</body>
</html>

SilkMcNasty
08-21-2002, 02:54 PM
Thank,
I had to add the NAME tag to the link and used the click() function, referencing the tag..

Thanx