Expanding a <div>

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

Martin Honnen

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

Kevin Quigley

Thanks very much martin, that worked fine.

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

Thanks again,
Kevin.
 

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
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top