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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submit Button 1

Status
Not open for further replies.

cyberprof

Programmer
Jun 10, 2003
229
GB
Can a hyperlink be used as a submit button on a form?

If so, how would you code it?

Cheers

J
 
yes
dynamically sibmitting the form in a client script function call or directly in the tag

<a href=&quot;#&quot; onClick=&quot;document.formname.submit();&quot;> submit </a>

many variations to this format
eg: <a href=&quot;javascript:void(0);&quot;




___________________________________________________________________
onpnt2.gif

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
 
Do I still have to start and end the form as normal but dont include an 'action' in the top of the form

<form method=post name=frmTest>

<a href=&quot;#&quot; onClick=&quot;document.frmTest.submit();&quot;> submit </a>


</form>
 
you need to structure the form exactely as you normally do. action needs to be set still.

the link does not function as a link when you perform these types of methods unless you dynamically do them in a script or otehr methiods.

___________________________________________________________________
onpnt2.gif

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
 
Cant get it to transfer the data to the next form, this is what I have

(newcomp1.asp)

<form action=&quot;post&quot; action=&quot;newcomp2.asp&quot; name=&quot;frmComp&quot;>
<input type=&quot;text&quot; name=&quot;company&quot;>
<input type=&quot;text&quot; name=&quot;address&quot;>
<a href=&quot;#&quot; class=&quot;navlink&quot; onClick=&quot;document.frmComp.submit();&quot;> Continue >>> </a>
</form>

---------
(newcomp2.asp)

<% cn = Request.Form(&quot;companyname&quot;)
ad = Request.Form(&quot;address&quot;)
Response.Write(cn)
Response.Write(ad)
%>

No data is being pass forward to newcomp2.asp
 
you are requesting the form collection in a way the form needs to be submitted via HTTP or POST methods.

either two solutions exist. method=&quot;post&quot; addition to the form tag or change you request to Request.QueryString

if the method is not included then it defaults to a GET method

___________________________________________________________________
onpnt2.gif

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
 
Sorry bout this, I've just spotted a error:
<form action=&quot;post&quot; action=&quot;newcomp2.asp&quot; name=&quot;frmComp&quot;>
should be
<form METHOD=&quot;post&quot; action=&quot;newcomp2.asp&quot; name=&quot;frmComp&quot;>

However, just tried again and still didn't work.

I swapped the hyperlink back to a submit button and the data transferred fine!!
 
<a href=&quot;#&quot; class=&quot;navlink&quot; onClick=&quot;document.frmComp.submit();&quot;>

form names do not match.

go through the code carefully and make sure your naming convent's are all matching

___________________________________________________________________
onpnt2.gif

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
 
whoops it does match. ignore that last one

___________________________________________________________________
onpnt2.gif

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
 
do you have a submit button on the page still with a name value set?

___________________________________________________________________
onpnt2.gif

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
 
if not jsut try this method then
<a href=&quot;javascript:document.frmComp.submit();&quot;>Submit</a>

if that does not work is there must be a error elsewhere in the page

___________________________________________________________________
onpnt2.gif

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
 
<a href=&quot;javascript:document.frmComp.submit();&quot;>Submit</a>

That works fine.

Thanks

 
Ok. Forget what you did and think about this. Do you need a hyperlink? If not, would this do?

<input type=&quot;submit&quot; name=&quot;Continue&quot; value=&quot;Continue&quot; style=&quot;border: none; text-decoration: underline; background: transparent; cursor: pointer; color: blue;&quot; />
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top