jdubwelch Posted December 4, 2007 Share Posted December 4, 2007 I'm making a form for selecting a winner from 32 games. the table has 3 columns and at least 32 rows: [away team] [home team] [picked winner] I need javascript to put the team that you click on into the "picked winner" cell of the table. and then I want to be able to submit/post all the teams in the "picked winner" cells to be handled by php. I don't like the idea of text fields, because I don't want a bunch of text fields on the page. (remember there's 32 games). How would I do this, or what is this called so I can google it for a tutorial of some sort. Any ideas, or help would be great. Here's the basic table i created for it. The first row of teams is what I want it to be like after the user clicked on Oregon. <form action="" method="post"> <table width="400" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="135">AWAY</td> <td width="133">HOME</td> <td width="132">WINNER</td> </tr> <tr> <td><a href="#">Oregon State </a></td> <td><a href="#">Oregon</a></td> <td>Oregon</td> </tr> <tr> <td><a href="#">Washington</a></td> <td><a href="#">Washington State</a> </td> <td> </td> </tr> <tr> <td colspan="3"><div align="center"> <input type="submit" name="Submit" value="Submit" /> </div></td> </tr> </table> </form> Link to comment https://forums.phpfreaks.com/topic/80075-seen-it-done-but-no-idea-how/ Share on other sites More sharing options...
BenInBlack Posted December 4, 2007 Share Posted December 4, 2007 try this <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled</title> </head> <body> <form action="" method="post"> <table width="400" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="135">AWAY</td> <td width="133">HOME</td> <td width="132">WINNER</td> </tr> <tr> <td><a href="javascript:void(0);" onClick="setWinner('Oregeon State',1);" id="linkaway1">Oregon State</a></td> <td><a href="javascript:void(0);" onClick="setWinner('Oregon',1);" id="linkhome1">Oregon</a></td> <td id="row1">Oregon</td> <input type=hidden id="winner1" value=""> </tr> <tr> <td><a href="javascript:void(0);" onClick="setWinner('Washington',2);" id="linkaway2">Washington</a></td> <td><a href="javascript:void(0);" onClick="setWinner('Washington State',2);" id="linkhome2">Washington State</a></td> <td id="row2"> </td> <input type=hidden id="winner2" value=""> </tr> <tr> <td colspan="3"><div align="center"> <input type="submit" name="Submit" value="Submit" /> </div></td> </tr> </table> </form> <script language="JavaScript" type="text/javascript"> <!-- function setWinner(clickedObjId,row) { document.getElementById('row'+row).innerHTML = clickedObjId; document.getElementById('winner'+row).value = clickedObjId; } // --> </script> </body> </html> Link to comment https://forums.phpfreaks.com/topic/80075-seen-it-done-but-no-idea-how/#findComment-406053 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.