Jump to content

tricking html to send $_post var with a link.. help please


just-j

Recommended Posts

ok im trying to trick html to send a $_POST var with a <a href> link..  im doing this by using some javascript to make the form submit be a text link and not a button or image so the form will send the POST to the .php page..  well when i click the link it does nothing...  here is the javascript.

[code]
<script language="JavaScript" type="text/javascript">
<!--
function getuser(selecteduser)
{
  document.usersform.userpicked.value = selecteduser ;
  document.usersform.submit() ;
}
-->
</script>
[/code]

and the next bit of code is a while loop in php that gets the users from a table in MySQL and sets each user as a link that is supose to call the javascript  but does nothing when i click it.
[code]
<?php
$result = mysql_query("SELECT genre, user FROM users");
$i = 0;
echo "<form name='usersform' action='member.php' method='post'>";
echo "<input type='hidden' name='userpicked' />";
while ($row = mysql_fetch_object($result)) {
echo "<a href='javascript:getuser($row->user)'>$row->user</a> Genre of choice: $row->genre <br />";
  $i++;
}
echo "</form>";
echo "$i users signed up";
?>
[/code]

now the php does everything it is supose to and when i hover over the link i get javascript:getuser(username) at the bottom of firefox. but when i click it i get nothing...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.