Baby JavaScript question

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.
 
V

Vidar Petursson

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
==============================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top