Forum Moderators: open

Message Too Old, No Replies

Submitting form with onclick events

         

Mister_L

3:57 pm on Nov 27, 2009 (gmt 0)

10+ Year Member



Hi,

My script contains a form as follows:

<form action="" name="nextpageform" method="post">
.
.
</form>

Then I have a link with onclick events.My intention is that the form be submitted by a click on that link, and action be set to the href attribute of the link. This is what I tried but I guess it is wrong:

<a href="URL string with php variables" onclick="document.nextpageform.action=this.href;document.nextpageform.submit();">link</a>

How do I fix it?

Thanks.

daveVk

2:36 am on Nov 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try

<a href="URL string with php variables" onclick="document.nextpageform.action=this.href;document.nextpageform.submit();return false;">link</a>

This will prevent the normal link action of going to the href after onclick complete;