Baby JavaScript question

  • Thread starter Thread starter Jim Owen
  • Start date Start date
J

Jim Owen

I never ever need to use Javascript, but in this case I think I do. All I
want is for a Calendar control to appear when the user clicks a button.
Being as this isn't worth a trip to the server, I want to add some JS to
make this happen. What is the script for that? I tried:

MyButton.Attributes.Add("onclick","document.forms[0].MyCalendar.Visible='Tru
e';");

Though of course I don't know what I'm doing.
 
Hi

This should toggle the element visibility passed to the function

function toggleElement(sElementID){
if(document.getElementById)
{
var e = document.getElementById(sElementId);
if( e != null ) e.style.visibility = ( e.style.visibility == "hidden") ?
"visible" : "hidden";
}
}

MyButton.Attributes.Add("onclick","toggleElement('ELEMENTID')" );
Where ELEMENTID is the calendar in your case

--
Best Regards
Vidar Petursson
==============================
Microsoft Internet Client & Controls MVP
==============================
 
Back
Top