It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming HTML Forum

Using a link as a submit button?

Using a link as a submit button?

Postby MM xSkillz on Fri Aug 22, 2008 12:22 am

Hi,

Is there a way to use a simple link as a submit button for a form? I want to do this so that I can make a link which rather than simply going to a page can do a method="post" and define a variable in PHP without it being in the URL (which is how you would normally do it but I don't want to do it that way because I want it hidden in the URL). Thanks in advance!
MM xSkillz
100+ Club
 
Posts: 196
Joined: Fri Mar 16, 2007 5:07 pm

Postby rangana on Fri Aug 22, 2008 12:30 am

You can have it. Normally, a link is just as simple as this:
Code: Select all
<a href="#">Link</a>


You can however command the link (via JS) that it should submit the form:
Code: Select all
<a href="#" onclick="document.NameofUrForm.submit()">Link</a>


You can replace NameofUrForm with your form name. You can also use getElementById() or accessing the document.forms[formINDEX].

Hope that makes sense.
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Postby MM xSkillz on Fri Aug 22, 2008 1:44 am

Cool, thanks!!!
MM xSkillz
100+ Club
 
Posts: 196
Joined: Fri Mar 16, 2007 5:07 pm

Postby rangana on Fri Aug 22, 2008 2:25 am

No problem.
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Re: Using a link as a submit button?

Postby sheena on Wed Sep 22, 2010 5:45 am

In the <FORM ...> tag there is a field called ACTION, specify the target web page address there. Now if you use <INPUT TYPE='submit'> for the button then there is no issue.. your problem is solved. That would be cool info here.



link submitting
sheena
 
Posts: 1
Joined: Wed Sep 22, 2010 5:43 am


Who is online

Users browsing this forum: No registered users and 6 guests