Posting information

  • tommya
  • Graduate
  • Graduate
  • tommya
  • Posts: 221
  • Loc: United Kingdom

Post 3+ Months Ago

is it possible to post a value via an imaged hyperlink, or can _POST variables only be set by using forms.

i want to stick an image on the end of a list summary, that when clicked, posts the reference number of the helpdesk request, but at the minute, I'm using a form with an image inside it

hope that makes sense
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • gsv2com
  • Professor
  • Professor
  • User avatar
  • Posts: 776
  • Loc: Nippon

Post 3+ Months Ago

Can you post a link to the current form so we can get a better idea of what you're thinking about doing?
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

You can use JavaScript to submit a form that is executed when a link is clicked. Put a link on the image, than put an onClick handler in the anchor tag that submits a form. Just use a hidden field to store the reference number for posting

Or, use the form element TYPE="image" That's basically the same as a submit button, but uses an image you specify instead of a button element

.c
  • tommya
  • Graduate
  • Graduate
  • tommya
  • Posts: 221
  • Loc: United Kingdom

Post 3+ Months Ago

thats exactly how I'm using it at present, with a hidden field storing the reference number and an image that when clicked, posts it.

However, it causing me a bit of a pain when I put it on the end of my list summary, because the image seems to take up rows worth of space, when the rest of the fields only require 1, as did (or so I thought) the image
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

Well, you can only send POST data using a form from an HTML page... Maybe try something like this:

Code: [ Select ]
<html>
<p><table>
<form ACTION="myprocessor.php" METHOD="POST" NAME="myform">
<input TYPE="hidden" NAME="refnum" VALUE="<?=$refnum?>">
<tr><td>

# YOUR FORM HERE #

</tr></td>
</form>
</table>

<p><a HREF="#" onClick="document.form.myform.submit();"><img SRC="button.gif" BORDER="0"></a>

</html>
  1. <html>
  2. <p><table>
  3. <form ACTION="myprocessor.php" METHOD="POST" NAME="myform">
  4. <input TYPE="hidden" NAME="refnum" VALUE="<?=$refnum?>">
  5. <tr><td>
  6. # YOUR FORM HERE #
  7. </tr></td>
  8. </form>
  9. </table>
  10. <p><a HREF="#" onClick="document.form.myform.submit();"><img SRC="button.gif" BORDER="0"></a>
  11. </html>


What this does is make the image NOT a form element anymore, but uses javascript to submit your form instead. It would mean that users will have to have JavaScript enabled to submit the form, however. If that could be a problem, you could use a sniffer and put a submit button inside the form for those few users. I tend to not worry too much about those freaks myself. If they've disabled JS (it's on by default in every browser I've seen), they're probably use to things not working very well. =]

.c
  • Mas Sehguh
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1853

Post 3+ Months Ago

tommya wrote:
is it possible to post a value via an imaged hyperlink, or can _POST variables only be set by using forms.

i want to stick an image on the end of a list summary, that when clicked, posts the reference number of the helpdesk request, but at the minute, I'm using a form with an image inside it

hope that makes sense


The desired effect makes sense, but not the desired method. Why not have the information be sent within the URL? It's just a number. You shouldn't be using javascript for things like this.

One way you _could_ do it if you insist on the http POST method is the following:

<form action="script" method="post" name="blegh">
<input type="image" src="image%20file" name="refnumber" value="34235262">
</form>

And when the image is selected, the empty form will be submitted with the ref number being whatever the value is.

It seems like you're using PHP to process these things. You could just have
Code: [ Select ]
<a href="script?refnumber=34235262"><img ...></a>
instead, and look at the _GET hash in your PHP script -- that is how I would suggest doing it.
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

using the method Sam described above would work, unless you have other data you want submitted along with the reference number. The URL string (AKA the GET method) is limited in length, and for a help desk ticket system, this could be a problem is a ticket request is very long.

I guess, really, I'm unclear exactly what the problem really is. Can you please post a link to your form? It would be helpful to see an example. It might be that some reorganization of your HTML code is all that is needed.

Thanks
.c
  • tommya
  • Graduate
  • Graduate
  • tommya
  • Posts: 221
  • Loc: United Kingdom

Post 3+ Months Ago

sorry for not posting any replies guys but I actually provided info on this in another post, sorry.
But to give you the jist, I found out about the GET method and seeing as all I posting is the reference number, it worked great for me.

Those last couple of posts have provided me with some ammo should I come across a similar problem in the future however, thanks for all the advice
  • Mas Sehguh
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1853

Post 3+ Months Ago

Carnix wrote:
using the method Sam described above would work, unless you have other data you want submitted along with the reference number. The URL string (AKA the GET method) is limited in length, and for a help desk ticket system, this could be a problem is a ticket request is very long.


The URL string is not technically limited in length, but there are practical limitations.

By the way, for the other poster, RFC 2068 (HTTP 1.1, 1997) mentions this:
Quote:
Note: Servers should be cautious about depending on URI lengths above 255 bytes, because some older client or proxy implementations may not properly support these lengths.

As it stands, you should keep URLs less than 256 bytes. Even if a URL is less than 256 bytes long, you might want to use POST data whenever it loses the practicality of being a URL.

Note that IE's URL limit is 2083 (with a path length limit of 2048), and that Netscape/Mozilla's is some higher value.

Post Information

  • Total Posts in this topic: 9 posts
  • Users browsing this forum: No registered users and 53 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.