Skip to main content
Karen_Little
Inspiring
July 9, 2006
Question

Can a href command be used to post rather than get?

  • July 9, 2006
  • 2 replies
  • 930 views
Hi - is there some way to use a standard href=myPage.cfm to post information rather than get, as in: href=myPage.cfm?topic=123
This topic has been closed for replies.

2 replies

BKBK
Community Expert
Community Expert
July 9, 2006
I don't think you can post a variable by means of a link. For example, doing <a href="myPage.cfm?form%2Etopic=123"> wont work. A link cannot create the form scope on the action page. Only tags like <form> and <cfhttp> can.

However, if you insist on using a link, Javascript could come in handy.

sender.cfm:

<a href="javascript: document.poster.submit()">Post it</a>
<cfform name="poster" action="myPage.cfm" format="HTML" method="POST">
<cfinput name="topic" type="Text" value="123">
</cfform>

myPage.cfm

<cfif isDefined("form.topic")>
form.topic: <cfoutput>#form.topic#</cfoutput>
</cfif>

July 9, 2006
You can do this but it's a bad idea.
  • It breaks the web paradigm which confuses users and breaks down their trust.
  • Visitors without javascript, or using mobile devices or voice readers will not be able to use your site.
  • Search engines can destroy your data!
  • Users with Firefox, etc., pre-fetch extensions can destroy your data!
  • Do you really want users to be able to bookmark say, "Delete this entry" or "Add new junk to my site with one click and no thought"?

A better way is to keep forms for posting and alter the submit button(s)' appearance, if you wish, without hiding its/their purpose.

Karen_Little
Inspiring
July 9, 2006
Do you know how to do it? You don't have to worry how I will use it.
Karen_Little
Inspiring
July 9, 2006
Hi - it's very easy to attach a url variable to a link. This forum, for example, uses that construct. What I'm looking for is the means to execute a post by using a link, rather than a form setup.