Jump to content

Seen it done, but no idea how.


jdubwelch

Recommended Posts

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
Share on other sites

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
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.