Forum Moderators: open

Message Too Old, No Replies

radio buttons with a text box

when text box is focused, the radio next to it is checked

         

macrost

3:54 pm on Nov 7, 2003 (gmt 0)

10+ Year Member



Hello,
Ok, here's the situation. My friend is working on a ballot system, and the form let's say has 5 radio buttons. Now on the fifth one, there's a text field for someone to enter a name into it. Now the problem is this: I need to have when the text field is focused, then the cooresponding radio be selected. I have tried numerous things, but none seem to work. Does anyone have any ideas?
Thanks,
Mac

macrost

4:34 pm on Nov 7, 2003 (gmt 0)

10+ Year Member



Ok, gots it figured out. Posting code just in case someone else might need it.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
function clearfield()
{
document.form1.second.value = "";
}
function checkme()
{
document.form1.first[1].checked = 1;
}
//-->
</SCRIPT>
</head>

<body>
<form name="form1">
<input type="radio" name="first" ONCLICK="javascript:clearfield();"> bleh
<br>
<input type="radio" name="first">
<input type="text" name="second" value="test" ONFOCUS="javascript:checkme();">
<input type="submit" name="4" value="click">

</form>

</body>
</html>

Mac