/    Sign up×
Community /Pin to ProfileBookmark

Submit a form using a text link

Hi, without using JavaScript, is it possible to submit a form, using a text link? – using a similar technique to that used in checking if a submit button has been clicked.

[CODE]if(@$_POST[‘Submit’])
{
[/CODE]

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@phantom007Jun 14.2008 — I think JS is the only way to submit a form using a text link.
Copy linkTweet thisAlerts:
@Declan1991Jun 15.2008 — You need JavaScript if you are to do that, and I'd advise against it.
Copy linkTweet thisAlerts:
@ayveghJun 16.2008 — You need JavaScript if you are to do that, and I'd advise against it.[/QUOTE]
Why would you advise against submitting by activating the form via JS?
Copy linkTweet thisAlerts:
@SyCoJun 17.2008 — Why would you advise against submitting by activating the form via JS?[/QUOTE]

If a user turns javascript off or is using a browser that isn't javascript enabled, how is the form submitted? Personally I think if people are so paranoid they turn off javascript, then they should use Linux! Still if it can be accommodated without degrading other users experiences then they ought to be.

You can use CSS to style a button to look like a text link, then it's the best of both worlds.

Incidentally if you use
[code=html]<form cation="scrip.php" method="post">
<input type="hidden" name="submit" value="1">
<input type="submit" value="Submit me">
</form>[/code]

Instead of naming the submit button you can submit the form using the return key even if there are multiple form on the same page. Whichever form was last focused will submit.

You then if() for the hidden value (which of course can be anything)
Copy linkTweet thisAlerts:
@ayveghJun 17.2008 — I see - good point, although from the visitor tracking software I run on my sites, I can see that those who do turn it off are the minority.

As far as looking for a hidden value, I use those when I need to known whether the form was submitted or not.

For example, if I have script.php?do=login, the hidden value will allow me to know if the user submitted or not, without having to check each field to see if one of them has a value.
×

Success!

Help @Dysan spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...