...

View Full Version : value of a button to a text box help?



supacook2k
11-07-2006, 09:58 PM
can someone help with some code for me please. i need to find out when i click a button it displays what it says on the button in a text box above it.
the code i have so far is





<html>
<head>

<script type="javascript">





</script>

</head>

<body>

<form name="display">

<input type="text" name="box" value ="">

<tr>
<td><input type="button" name="one" value="1"></td>
<td><input type="button" name="two" value="2"></td>
<td><input type="button" name="three" value="3"></td>
</tr>

</body>
</html>




now i know i'll need an onclick event but not sure how i get the info to display in the box

cheers for any help guys.

brandonH
11-07-2006, 10:37 PM
<html>
<head>

<script type="text/javascript" for=buttoN event=onclick>
var val=this.value;
document.getElementById('text1').value=val;
</script>

</head>

<body>

<form name="display">

<input type="text" name="box" value ="" id=text1>

<tr>
<td><input type="button" name="one" value="1" id=buttoN></td>
<td><input type="button" name="two" value="2" id=buttoN></td>
<td><input type="button" name="three" value="3" id=buttoN></td>
</tr>

</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum