Forum Moderators: open

Message Too Old, No Replies

Disable/Enable a text box using a Radiobutton

Filled, Enables, Unfilled, Disabled.

         

mrDaf

4:48 pm on Jun 23, 2004 (gmt 0)

10+ Year Member



I've searched this site using the search engine, and I just cannot find anything like this anywhere.

Is it possible to have a textbox, that is enabled, or disabled on the condition that a radio button in the same form is filled, or unfilled respectively?

mrDaf

8:28 pm on Jun 23, 2004 (gmt 0)

10+ Year Member



When I said radio button, I meant a check box, but I can't seem to edit my posts anymore.

I've come up with this so far.

<script language="javascript">
function enableField()
{
if (document.html_form.checkbox.checked == true){
document.html_form.select_menu.disabled=false;
}else {
document.html_form.select_menu.disabled=true;
}
}
</script>

My select_menu starts off disabled.

The function is called using:

onFocus="Javascript:enableField();"

on my checkbox.

In theory, it should work, but it doesn't.

Can anyone help?

mrDaf

9:21 pm on Jun 23, 2004 (gmt 0)

10+ Year Member



Where's the resolve button.

I got it to work by changing the onFocus to onClick.

Sorted.