Click to See Complete Forum and Search --> : Need HELP with a function


mongous
12-20-2002, 01:04 PM
I am trying to set the 'visibility' property for a text box (on a form) to 'visible' - based on the choice in the select box.

Am I even close?

>
function show2(){
var TimeType = document.frm.TypeOfTimeOff.value;

if(TimeType.value = "Medical Appt."){
frm.TimeOfAppt.style.visibility = "visible";
}
}


<SELECT size=1 name=TypeOfTimeOff>
<OPTION value=Vacation selected>Vacation (Planned)</OPTION>
<OPTION value="Floating Holiday">Floating Holiday (Planned)</OPTION>
<OPTION value="Medical Appt." onChange="show2();">Medical Appt.</OPTION>
<OPTION value=Sickleave>Sick Leave (Unplanned)</OPTION>
<OPTION value=Leavewopay>LWOP (Approval req.)</OPTION>
<OPTION value="FMLA/LOA">FMLA/LOA (Approval req.)</OPTION>
<OPTION value="Jury Duty">Jury Duty</OPTION>
<OPTION value=bereavement>Bereavement</OPTION>
</SELECT>

Tricky123
12-20-2002, 01:31 PM
As far as I am aware in my limited JS experience, it is not possible to call a function from with your select <options>. It must be called from the <select> tag. You would then need to use...

<HTML>
<form name="frm">
<BODY>
<script language="javaScript">


function show()
{
if (document.frm.TypeOfTimeOff.options[2].selected)
{
// i don't know the code to make a form show, sorry
//document.frm.TimeOfAppt.style.visibility = "visible";
alert("The form should change");
}
}
</script>

<SELECT size=1 name="TypeOfTimeOff" onClick="show()">
<OPTION value=Vacation selected>Vacation (Planned)</OPTION>
<OPTION value="Floating Holiday">Floating Holiday (Planned)</OPTION>
<OPTION value="Medical Appt." ">Medical Appt.</OPTION>
<OPTION value=Sickleave>Sick Leave (Unplanned)</OPTION>
<OPTION value=Leavewopay>LWOP (Approval req.)</OPTION>
<OPTION value="FMLA/LOA">FMLA/LOA (Approval req.)</OPTION>
<OPTION value="Jury Duty">Jury Duty</OPTION>
<OPTION value=bereavement>Bereavement</OPTION>
</SELECT>

</BODY>
</HTML>

This will give you an alert if the medial appt. option is clicked! I don't know how to change form visibility however, but its a start!!

Happy Hols!!

khalidali63
12-20-2002, 01:33 PM
when you reference a form you should reference it properly with the document.like this

document.frm.TimeOfAppt.style.visibility = "visible";

cheers

Khalid

mongous
12-20-2002, 01:47 PM
Thank you both so much! You got me going in the right direction! That was all I needed! It works!

Thanks again.