General discussion

Locked

Radio Buttons & Text Buttons

By vhansen86 ·
I have a form with several textboxes with radio buttons. I have everything working the way I need to except for when the textbox is clicked I want the radio button to show it is checked. I have it working vice versa and once one item is checked the one previously checked is unchecked.

<HTML>
<style>
.hrefstyle{
color=black;
text-decoration:none;
}
</style>

<script language="JavaScript">

function click(which) {
document.formname.Chk_field[which].checked = true;


}

</script>
<body>

<form name="formname">

<input type="RADIO" name="Chk_field" value="1"
OnClick="document.formname.textbox1.focus();return true;">
<A HREF="javascript:click(0)" class="hrefstyle"></A><input type="textbox" name="textbox1"></p>

<input type="RADIO" name="Chk_field" value="1"
OnClick="document.formname.textbox2.focus();return true;">
<A HREF="javascript:click(1)" class="hrefstyle"></A>
<input type="textbox" name="textbox2"></p>


<input type="RADIO" name="Chk_field" value="1"
OnClick="document.formname.textbox3.focus();return true;">
<A HREF="javascript:click(2)" class="hrefstyle"></A>
<input type="textbox" name="textbox3"></p>

</form>

</body>
</HTML>

<!---End of Source code--->

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Radio Buttons & Text Buttons

by allenhunter In reply to Radio Buttons & Text Butt ...

If you change the names of the radio buttons so that they are unique, you can then easily change their checked status with the onfocus and onblur events of the text boxes. Add the following code to the textbox tags...

onfocus="document.formname.Chk_field1.checked='checked'"
onblur="document.formname.Chk_field1.checked=''"

Make sure to change the names where appropriate.

Collapse -

Radio Buttons & Text Buttons

by vhansen86 In reply to Radio Buttons & Text Butt ...

Thanks for the effort though. Could not get it to work.

Collapse -

Radio Buttons & Text Buttons

by vhansen86 In reply to Radio Buttons & Text Butt ...

This question was closed by the author

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums