Discussion Locked

Force a Submit on a form load?

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

How can you click a SUBMIT button using CODE?

I would like to use a form POST or GET in a ASP page without needing the visitor to click the Submit button.

In VB you can click any button by changing the VALUE of the object. Seems like either (windows.object.submit = True or document.all.object(1) = -1) VBSCRIPT or JSCRIPT should be able to trick the browser into sending its 'pair values' to another ASP page.

5 replies

by b1xml2

Try this:-

Conditional Submission

Notes:-
------
1. It is considered bad "form" (pun intended!) to submit forms without user action.
2. The onchange event is used for input types:- text, password as well as select and textarea elements.
3. The onclick event is used for input types radio and checkbox.
4. Cross browser scripting would require you to check the type. If the supported browsers implement DOM properly, you can check the element.tagName instead of the element.type.
Select elements have two values: select-one and select-multiple.
5. To submit a form via code, use the document.formName.submit() method.
6. It is good to have some validation, trimming leading and trailingspaces client-side. Saves work on the server.
7. Regular Expression is supported in Javascript 1.2 and above. You would have to write your own function
to trim values for older browsers using the substring and charAt methods.
Regards,
Brandon Driesen
Senior Analyst Programmer

by 3wadman

That worked well, thanks!

FYI: Form POST is the only easy way to securely send record set fields from a SQL to a SSL without the users knowledge.(You lose your seesion variables when you go from non-SSL to SSL)

This discussion is closed to new replies.