post get without forms

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
fred
Forum Newbie
Posts: 7
Joined: Wed Jul 24, 2002 11:18 am
Location: England / Deutschland

post get without forms

Post 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?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Why do you want to use post for this?

Mac
gnu2php
Forum Contributor
Posts: 122
Joined: Thu Jul 11, 2002 2:53 am

Post 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.
User avatar
fred
Forum Newbie
Posts: 7
Joined: Wed Jul 24, 2002 11:18 am
Location: England / Deutschland

Post 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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Then why not use an actual form and some radio buttons?

Mac
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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)
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
fatalcure
Forum Contributor
Posts: 141
Joined: Thu Jul 04, 2002 12:57 pm
Contact:

Post 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 :)
User avatar
fred
Forum Newbie
Posts: 7
Joined: Wed Jul 24, 2002 11:18 am
Location: England / Deutschland

Post 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:
Post Reply