By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,676 Members | 1,759 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,676 IT Pros & Developers. It's quick & easy.

Submit a form with hyperlink

P: n/a
Hello All!

Is it possible to submit a form using hyperlink? I want to send hidden element
when a link is clicked. I read some books, but I found only using button which I
don't want to use.

Thanks in advance.
Jul 20 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
ry**@yokoyama.ws wrote in
news:MP************************@news.corenews.com:
Hello All!

Is it possible to submit a form using hyperlink?
Not in HTML.
I want to send
hidden element when a link is clicked. I read some books, but I found
only using button which I don't want to use.


So you want a hyperlink to submit a form that _only_ has a hidden field?
As in, the user doesn't type anything? They way you do this is with the
URL:

Say you wanted to send the data in two hidden fields:
<input type="hidden" name="blah" value="clam">
<input type="hidden" name="blegh" value="homestar">

Just drop the hidden fields and put it in a URL like this, making sure to
escape the ampersand with &amp;:

<a href="path/pagename.extension?blah=clam&amp;blegh=homestar">L inky
Linky</a>

However, if you want to submit a form in which a user enters any sort of
input, then a button is the way to go.

--
In a room with thirty-seven people, never have everybody shake each
other's hand.
Jul 20 '05 #2

P: n/a
you can use Javascript :

<form name="myForm" method="post" action="myscript.pl">
<input type="hidden" value="10">
</form>
<script language="javascript>
document.myForm.submit();
</script>

ry**@yokoyama.ws wrote:
Hello All!

Is it possible to submit a form using hyperlink? I want to send hidden element
when a link is clicked. I read some books, but I found only using button which I
don't want to use.

Thanks in advance.


Jul 20 '05 #3

P: n/a
Greg Griffiths wrote:
you can use Javascript :

<form name="myForm" method="post" action="myscript.pl">
<input type="hidden" value="10">
</form>
<script language="javascript>
document.myForm.submit();
</script>


I think you meant something more like:
<script language="javascript>
function submit() {
document.myForm.submit();
}
</script>
....
<a href="javascript:submit();">submit</a>

However, don't do this unless you provide a button as a fall back.
Better yet, just use a button, and use CSS to style so it looks like a
link. Other than the presentation, I can't imagine any reason for using
a link instead of a real button.

--
Lachlan Hunt
http://www.lachy.id.au/

Please direct all spam to ab***@127.0.0.1
Thank you.
Jul 20 '05 #4

P: n/a
Lachlan Hunt wrote:
I think you meant something more like:
<script language="javascript>
Oops, that should have been:
<script type="text/javascript">
or
<script type="application/x-javascript"> (this one does not work in IE)
function submit() {
document.myForm.submit();
}
</script>
...
<a href="javascript:submit();">submit</a>

However, don't do this unless you provide a button as a fall back.
Better yet, just use a button, and use CSS to style so it looks like a
link. Other than the presentation, I can't imagine any reason for using
a link instead of a real button.

--
Lachlan Hunt
http://www.lachy.id.au/

Please direct all spam to ab***@127.0.0.1
Thank you.
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.