donvitto donvitto - 1 year ago 78
HTML Question

submit form from a link

This is what I am trying to do without success :

<form name="something" action="ht.php" method="post">
<a href="#" onclick="document.url.submit('helloworld');">Submit</a>

When I click on the link I want to post the value
. How can I do this?

Answer Source

You can't just do document.url.submit(), it doesn't work like that.

Try this:

<form id="myForm" action="ht.php" method="post">
    <input type="hidden" name="someName" value="helloworld" />
    <a href="#" onclick="document.getElementById('myForm').submit();">Submit</a>

That should work!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download