Jump to content

Exandible list doesn't work in Internet Explorer


pianoman993

Recommended Posts

Here is an expandable list. The problem is, it doesn't work in internet explorer (It displays everything on load instead of being collapsed). However this script runs great in everything but! .. go figure :/

 

If anyone has a solution, I would greatly appreciate it!

 


function toggle(id) {
    ul = id;
    img = "arrow_" + id;

    ulElement = document.getElementById(ul);
    imgElement = document.getElementById(img);

    if (ulElement){
            if (ulElement.style.display=='none'){
                ulElement.style.display=''
                imgElement.src = "img/icons/arrow_top.gif";
            }else{
                ulElement.style.display='none'
                imgElement.src = "img/icons/arrow_down.gif";
            }
    }             
}

 

Thanks,

Mark

Link to comment
Share on other sites

Yes but I have to warn you.. it's not pretty

 


<div class="profile_list">
    <ul>
        <li class="border">
        	<a href="#" onClick="toggle('about_me')">
            	<img height="12" width="12" style="border:0px;float:left;padding-right:5px;" id="arrow_about_me" src="<?=base_url()?>img/icons/arrow_down.gif" />
            </a>
            <a href="#" onClick="toggle('about_me')"><b>About Me</b></a>
            <div id="about_me" style="margin-left:10px;margin:5px 10px 5px 15px;">
            	<?=form_open('profile/modifyprofile/'.$this->uri->segment(3))?>
                <textarea class="textarea" name="field_data" ><?=$field_about_me?></textarea><br />
                <input type="hidden" name="field_name" value="about me" />
            	<input type="submit" name="modify" value="Modify" style="font-size:11px;border:1px solid #CCC;margin-top:5px;" />
                </form>
            </div>
        </li>
        
        <li class="border">
        	<a href="#" onClick="toggle('contact_info')">
            	<img height="12" width="12" style="border:0px;float:left;padding-right:5px;" id="arrow_contact_info" src="<?=base_url()?>img/icons/arrow_down.gif" />
            </a>
            <a href="#" onClick="toggle('contact_info')"><b>Contact Information</b></a>
            <div id="contact_info" style="margin-left:10px;margin:5px 10px 5px 15px;">
            	<?=form_open('profile/modifyprofile/'.$this->uri->segment(3))?>
            	<textarea class="textarea" name="field_data" ><?=$field_contact_info?></textarea><br />
                <input type="hidden" name="field_name" value="contact information" />
            	<input type="submit" name="modify" value="Modify" style="font-size:11px;border:1px solid #CCC;margin-top:5px;" />
                </form>
            </div>
        </li>
        
        <li>
        	<a href="#" onClick="toggle('website')">
            	<img height="12" width="12" style="border:0px;float:left;padding-right:5px;" id="arrow_website" src="<?=base_url()?>img/icons/arrow_down.gif" />
            </a>
            <a href="#" onClick="toggle('website')"><b>Website</b></a>
            <div id="website" style="margin-left:10px;margin:5px 10px 5px 15px;">
            	<?=form_open('profile/modifyprofile/'.$this->uri->segment(3))?>
            	<input type="text" class="textfield" name="field_data" value="<?=$field_website?>" /><br />
                <input type="hidden" name="field_name" value="website" />
            	<input type="submit" name="modify" value="Modify" style="font-size:11px;border:1px solid #CCC;margin-top:5px;" />
                </form>
            </div>
        </li>        
    </ul>
    </div>
    
</div>

<script>
toggle('about_me');
toggle('contact_info');
toggle('website');
</script>

Link to comment
Share on other sites

I don't see any code that would initially hide those divs at all. Do you have a custom css style for all divs? If not, try changing the div's style to this:

<div id="about_me" style="margin-left:10px;margin:5px 10px 5px 15px;display:none">

 

Also, in the toggle function, I would suggest setting the display back to the default instead of just '' and you are missing two semi-colons:

function toggle(id) {
    ul = id;
    img = "arrow_" + id;

    ulElement = document.getElementById(ul);
    imgElement = document.getElementById(img);

    if (ulElement){
            if (ulElement.style.display=='none'){
                ulElement.style.display='block';
                imgElement.src = "img/icons/arrow_top.gif";
            }else{
                ulElement.style.display='none';
                imgElement.src = "img/icons/arrow_down.gif";
            }
    }             
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.