Click to See Complete Forum and Search --> : Need Help, radio buttons that get value from text


backcg1
07-26-2004, 06:00 PM
I have some radio buttons that assign the price of an item.(ie radio button 1 = 50, radio button 2 = 40 radio button 3 = 30, etc) I would also like for one of the radio buttons to be atached to a text field so that when that button is selected, whatever the price the user types into the text field becomes the value of the radio button. How can I do this?

HaganeNoKokoro
07-26-2004, 06:42 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Radio Button Example</title>
<script type="text/javascript">
function setValue(e1, e2) {
document.getElementById(e1).value=document.getElementById(e2).value;
}
</script>
</head>
<body>
<form id="radioForm">
<input type="radio" name="r1" value="50"></input>50<br/>
<input type="radio" name="r1" value="40"></input>20<br/>
<input type="radio" name="r1" value="30"></input>30<br/>
<input type="radio" id="uvr1" name="r1" value="0"></input>
<input type="text" value="0" id="uv1" onkeyup="setValue('uvr1', 'uv1')"></input><br/>
<input type="radio" id="uvr2" name="r1" value="0"></input>
<input type="text" value="0" id="uv2" onkeyup="setValue('uvr2', 'uv2')"></input><br/>
</form>
</body>
</html>

backcg1
07-27-2004, 12:46 PM
that worked out great, thanks HaganeNoKokoro!