You are here: Re: using hyperlinks as submit buttons « HTML « IT news, forums, messages
Re: using hyperlinks as submit buttons

Posted by Andy Dingley on 11/25/08 11:51

Alexander Weiner wrote:
> It is absolutely necessary, that all the parameters are send by post and not
> by get.

Then you _must_ submit from a <form>, not an <a> link (OK, so you
could do some AJAX-like thing too)

You have three options: CSS, JavaScript or a lot of JavaScript.

For CSS you make a bog-standard <form> with a submit button on it, then
you use CSS to make it look as much like an <a> as possible. This is
the simplest and most robust.

For JavaScript then you code a HTML <a> as normal, code a <form> as
well, then you use JavaScript to trap the <a onclick=... > event and
use it to do a form submit instead. jojo had the right idea, but coded
it unworkably badly. Return false afterwards, or else the <a> will
still try and navigate somewhere. What to set the <a href=... >
attribute to depends on what you wnat to happen for non-JS users. If
you want them to be disabled safely, then use href="#". If you permit
them to submit via a GET, but at least have something still working,
then set this link in the href as normal. Returning false will guard
against double submissions.

With a whole bunch of JavaScript and AJAX, you can do it without the
extra HTML coding.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация