I know I know how to do this but...
I have a form with two input boxes for two different values. I have three buttons labeled ONE, TWO and THREE. You type info into the fields and click whatever button. If you click TWO, then the information is associated with TWO.
Ok, now I got three DIVs to display what is in ONE, TWO and THREE respectively.
What I want is a function that reads in the input values, formats them and sends them to the appropriate DIV. I have all of it but the last part. Whats the DOM for doing this?
In case what I say is confusing...
Code:
<html>
<head>
<title> xxx </title>
<script type="text/javascript">
<!--
function playerCard(card) {
var pName = document.getElementByName('player_name');
var tName = document.getElementByName('team_name');
var info = pName + " plays for the " + tName;
}
//-->
</script>
</head>
<body>
<form name="card_form">
<p>Player Name: <input type="text" name="player_name" /></p>
<p>Team Name: <input type="text" name="team_name" /></p>
<p>
<input type="button" value="Card 1" onClick="playerCard('1')" />
<input type="button" value="Card 2" onClick="playerCard('2')" />
<input type="button" value="Card 3" onClick="playerCard('3')" />
</p>
</form>
<div id="card1"> </div>
<div id="card2"> </div>
<div id="card3"> </div>
</body>
</html>
Inside the script function, I want it to put the variables into the appropriate DIV, depending on the button clicked.
|