Click to See Complete Forum and Search --> : Help with intrinsic events and Forms!


mongous
12-19-2002, 01:55 PM
I am trying to use the onClick event to change the disabled status and background color of an input box.

I have two option buttons - 'Full day' and 'Partial Day' (it is a time-off request form). The 'times-requested' input box starts off disabled and greyed out.

I want the input box to 'enable' and change from grey to white when the correct radio button (Partial Day) is clicked, and vice-versa if they change their mind and click 'Full Day.

I got it to 'enable' but can't get the color to change. I have tried both using a function and calling it, and just using the onClick event (but i am a newbie).


Does all this make sense? Can anyone offer any suggestions? It would be greatly appreciated!

Here is an example of what I am trying to do:


<INPUT TYPE="Radio" NAME="HowMuchTime" VALUE="Partial Day" OnClick="times_requested.disabled=false">
<font color="#FF0000" size="-1">------------> <em>If Partial Day - Times Requested:</em></font>&nbsp;
<INPUT disabled size=22 name=times_requested>

khalidali63
12-19-2002, 03:53 PM
How about the code below mongous

Khalid

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

<html>
<head>
<title>Untitled</title>
<script language="JavaScript1.2">
/*
Author Khalid Ali
Date December 19, 2002

Code written for
*/
function process(){
var frm = document.frm;
var len = frm.length;
for(x=0;x<len;x++){
if(frm[x].type=="radio" && frm[x].checked){
if(frm[x].value=="Full Day"){
frm.timeSelected.style.visibility = "hidden";
}else if(frm[x].value=="Partial Day"){
frm.timeSelected.style.visibility = "visible";
}
}
}
}
</script>
</head>

<body>
<form name="frm">
<input type="Radio" name="time" value="Full Day" onclick="process();" checked>Full Day</input>
<input type="Radio" name="time" value="Partial Day" onclick="process();" >Partial Day</input>
<input type="Text" name="timeSelected" style="visibility:hidden;" ></input>
</form>


</body>
</html>

mongous
12-19-2002, 04:06 PM
Wow. That rocks! Thanks alot khalidali63!