Forum Moderators: open

Message Too Old, No Replies

Javascript and forms

         

thorevenge

4:21 pm on Jul 27, 2005 (gmt 0)

10+ Year Member



Hi I am looking for some help concerning javascript and forms.

Currently I have a form that has no submit button to it, however the information to the form is processed via php when a link is clicked (the link has a php variable).

What I want to know is, can I tie the submit buttons functionality to a standard <a href="" onclick=""> that will simulate as though a submit button has been pressed or do i have to create a submit button and just live with it?

Thanks for any suggestions

jatar_k

6:39 pm on Jul 27, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you can create a standard button the will call a function onclick and then that can submit the form form.submit() or it can just swap the window.location if you want

thorevenge

12:43 am on Jul 28, 2005 (gmt 0)

10+ Year Member



What I was hoping to do, was to create a hyperlink that can submit the form and change the URL, partly because it has to pass along the logout information in the URL, and because I don't want to have to use a button if I don't have to.

Thanks for the suggestion though!

Anyone else?

thorevenge

12:49 am on Jul 28, 2005 (gmt 0)

10+ Year Member



I ended up finding a solution. Thanks for trying everyone.

Solution was generically:
Head
<SCRIPT language="JavaScript">
function submitform()
{
document.the_form.submit();
}
</SCRIPT>

Body
<a href="javascript: submitform()" name="submit" onclick="window.location.href='index.php'">Submit</a>

And this both submitted the form and redirected as necessary.

Thanks again

jatar_k

1:31 am on Jul 28, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



glad you found it thorevenge

same premise as what I meant ;)