Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submit form using hyperlink 1

Status
Not open for further replies.

SH4F33

Programmer
Apr 1, 2005
58
MU
Hello, Im having a little problem for submitting a form. Basically the form has only one <input> element Where the user will put a number.
Below the from, I have several links each having specific querystrings generated from the DB. When the user click on any hyperlink, I want to submit the form, carrying the value to the next page + the querystrings.
Ive tried a simple example as the current page Im working on looks confusing with all the code.

Here's part of the example:
Code:
<form name="frmPost" method="POST" action="display.asp">
<input type="text" name="txtName">
</form>
<p>
<a href="#" onclick="document.frmPost.action='display.asp?param1=hello&param2=world';frmPost.Submit();">Submit form</a>

But nothing happens and the "Error on page" message appears in IE ststusbar. When clicking on error details, the error seems to be on the <a href... linke on character 65; i.e, param1.

Is there something wrong in the hyperlink?

Thank you very much for any help.
 
couple things...

add a return false.

Code:
<a href="#" onclick="...; return false;">
refer to your form in the same manner: document.frmPost. in one statement you have document.frmPost, in another you only have frmPost.

*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
Code:
<a href="#" onclick="document.frmPost.action='display.asp?param1=hello&param2=world';frmPost.Submit();return false;">Click Here to submit form</a>

Still the same error message in the statusbar.
 
Code:
Problems with this webpage might prevent it from being displayed properly or functioning properly....

Line: 12
Char: 65
Error: Object doesn't support this property or method.
Code: 0
URL: [URL unfurl="true"]http://127.0.0.1/page1.asp[/URL]

Line 12 is the <a href... line
Char 65 param1<--
 
Code:
<%@ language="VBSCRIPT" %>
<html>
<head>
<meta name="GENERATOR" content="SAPIEN Technologies PrimalScript 4.0">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Form Post</title>
</head>
<body>
<form name="frmPost" method="POST" action="display.asp">
<input type="text" name="txtName">
<p>
<a href="#" onclick="document.frmPost.action='display.asp?param1=hello&param2=world';frmPost.Submit();return false;">Click Here to submit form</a>
</form>
</body>
</html>

Thanks for sparing a little time for me. I appreciate.
 
ooh my. Thats a super jeez :) .Thank you very much man. I wish I could give double stars. BTW, HTML code in general, is it case-sensitive?
 
HTML? no. but the future (xHTML) will lead us to lower-casing standards. that means tags, events, attributes, and css elements.

*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top