just-j Posted July 18, 2006 Share Posted July 18, 2006 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... Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted July 18, 2006 Share Posted July 18, 2006 Why not use the GET method to pass the variable to the next page?You may also want to put the username in quotes when you call the js function:[code]echo "<a href=\"javascript:getuser('$row->user')\">$row->user</a> Genre of choice: $row->genre <br />";[/code] Quote Link to comment Share on other sites More sharing options...
just-j Posted July 18, 2006 Author Share Posted July 18, 2006 that works thanks!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.