Expanding a <div>

  • Thread starter Thread starter Kevin Quigley
  • Start date Start date
K

Kevin Quigley

Hi,

Does anyone know how to expand the area in a div tag when the
selectedindexchanged event fires?

I can get this to work when the user clicks a button, using the
following javascript function.....

function expandDiv(ctrl)
{
ctl = eval(ctrl)
if (ctl.style.display == "none")
{
ctl.style.display = "";
}
else
{
ctl.style.display = "none";
}
}

and setting the onclick event of a asp button....

Button1.Attributes["onClick"] = "javascript:expandDiv('maindiv')";

I've tried ddlYesNo.Attributes["OnSelectedIndexChanged"] =
"javascript:expandDiv('maindiv')";
but it doesn't seem to work.

Any help would be gratefully appreciated.

Thanks.
 
Kevin Quigley wrote:

Does anyone know how to expand the area in a div tag when the
selectedindexchanged event fires?

I can get this to work when the user clicks a button, using the
following javascript function.....

function expandDiv(ctrl)
{
ctl = eval(ctrl)
if (ctl.style.display == "none")
{
ctl.style.display = "";
}
else
{
ctl.style.display = "none";
}
}

Put
<script type="text/javascript">
function toggleDisplay (elementId) {
var element;
if (document.getElementById) {
element = document.getElementById(elementId);
if (el && el.style) {
if (el.style.display == 'none'; {
el.style.display = '';
}
else {
el.style.display = 'none';
}
}
}
}
</script>
in the <head> section of you page and then try setting

ddlYesNo.Attributes["onchange"] = "toggleDisplay('maindiv');";

If that doesn't work then post the markup you use to insert
ddlYesNo
in the page so that we exactly no what kind of control it is.
 
Thanks very much martin, that worked fine.

I think I'll have to brush up on javascript.

Thanks again,
Kevin.
 
Back
Top