Page 1 of 1

post get without forms

Posted: Fri Jul 26, 2002 4:28 am
by fred
Is it posible for a link (not a form) to use method POST.

<a href="link.php" method="POST">link</a>

I wish to moderate user comments, with something that looks like:

Fred: I like the pictures! moderate 0 1 2 3 4 5

<a href="moderate.php?ID=1234&moderate=4" method="POST"> 4</a>[/b]

I can currently only do this with a form. But forms can only use Buttons or Images as the action not a link.

Any thoughts?

Posted: Fri Jul 26, 2002 4:56 am
by twigletmac
Why do you want to use post for this?

Mac

Posted: Fri Jul 26, 2002 5:02 am
by gnu2php
Links always use GET, as far as I know.

I wonder if it's possible to do it in JavaScript. Maybe something like:

Code: Select all

<a href="..." onClick="post_form()">
But probably not.

Posted: Fri Jul 26, 2002 6:40 am
by fred
twigletmac wrote:Why do you want to use post for this?

Mac
Why... Because it will change the contence of the Database, and therefore is a POST.

If it was a normal link with a GET then a "search engine" could dig through these links and therefore change the Datebase values.

Posted: Fri Jul 26, 2002 6:43 am
by twigletmac
Then why not use an actual form and some radio buttons?

Mac

Posted: Fri Jul 26, 2002 6:59 am
by volka
if you really don't want to use forms as widgets you still may use them as hidden 'transport-objects'
Make forms with type="hidden"-elements only and let onClick-JavaScripts submit them.
I would 'group' the form and the onClick-Element within a <div> or <span> to identify the form. Something like

Code: Select all

<div><form method="post">....</form>
<a href="JavaScript:void(0)"; onClick="this.parentElement.children&#1111;0].submit();">....
</a></div>
^__ not tested at all ;)

(if you try this please let me know if it works or not)

Posted: Fri Jul 26, 2002 7:05 am
by twigletmac
This may be of interest to some people:
http://www.evolt.org/article/Forms_and_ ... index.html

How you do this sort of thing really depends on what you think of accessiblity.

Mac

Posted: Fri Jul 26, 2002 9:50 am
by fatalcure
try this:

Code: Select all

<?php echo "Value is: $moderate"; ?>

<script language="javascript">
<!--
function getModerate(whichone) &#123;
     document.moderate_form.moderate.value = whichone
     moderate_form.submit();
&#125;
</script>

<form name="moderate_form" method="POST" action="testing.php">
<input type="hidden" name="moderate" value="1">
<table><tr><td>
     <a href='javascript:getModerate(1)'>1</a>
     <a href='javascript:getModerate(2)'>2</a>
     <a href='javascript:getModerate(3)'>3</a>
     <a href='javascript:getModerate(4)'>4</a>
     <a href='javascript:getModerate(5)'>5</a>
</td></tr></table>
</form>
i think it'll work for you :)

Posted: Fri Jul 26, 2002 10:34 am
by fred
Thanks fatalcure !

Perfect! Just what I was looking for!

Code: Select all

echo 'Value is:'. $_POST&#1111;'moderate'];
But I guess I should use the new non global method :wink: