sandy1028 Posted July 20, 2007 Share Posted July 20, 2007 Hi, The contents are not getting aligned... Please help me with this <style type="text/css"> #containerul, #containerul ul{ text-align:left; margin:0; /* Removes browser default margins applied to the lists. */ padding:0; /* Removes browser default padding applied to the lists. */ } #containerul li{ margin:0 0 0 30px; /* A left margin to indent the list items and give the menu a sense of structure. */ padding:0; /* Removes browser default padding applied to the list items. */ list-style-type:none; /* Removes the bullet point that usually goes next to each item in a list. */ } #containerul .symbols{ /* Various styles to position the symbols next to the items in the menu. */ float:left; width:12px; height:1em; background-position:0 50%; background-repeat:no-repeat; } </style> <script> var temp, temp2, cookieArray, cookieArray2, cookieCount; function initiate(){ cookieCount=0; if(document.cookie){ cookieArray=document.cookie.split(";"); cookieArray2=new Array(); for(i in cookieArray){ cookieArray2[cookieArray[i].split("=")[0].replace(/ /g,"")]=cookieArray[i].split("=")[1].replace(/ /g,""); } } cookieArray=(document.cookie.indexOf("state=")>=0)?cookieArray2["state"].split(","):new Array(); temp=document.getElementById("containerul"); for(var o=0;o<temp.getElementsByTagName("li").length;o++){ if(temp.getElementsByTagName("li")[o].getElementsByTagName("ul").length>0){ temp2 = document.createElement("span"); temp2.className = "symbols"; temp2.style.backgroundImage = (cookieArray.length>0)?((cookieArray[cookieCount]=="true")?"url(minus.png)":"url(plus.png)"):"url(plus.png)"; temp2.onclick=function(){ showhide(this.parentNode); writeCookie(); } temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild) temp.getElementsByTagName("li")[o].getElementsByTagName("ul")[0].style.display = "none"; if(cookieArray[cookieCount]=="true"){ showhide(temp.getElementsByTagName("li")[o]); } cookieCount++; } else{ temp2 = document.createElement("span"); temp2.className = "symbols"; temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild); } } } function showhide(el){ el.getElementsByTagName("ul")[0].style.display=(el.getElementsByTagName("ul")[0].style.display=="block")?"none":"block"; el.getElementsByTagName("span")[0].style.backgroundImage=(el.getElementsByTagName("ul")[0].style.display=="block")?"url(minus.png)":"url(plus.png)"; } function writeCookie(){ // Runs through the menu and puts the "states" of each nested list into an array, the array is then joined together and assigned to a cookie. cookieArray=new Array() for(var q=0;q<temp.getElementsByTagName("li").length;q++){ if(temp.getElementsByTagName("li")[q].childNodes.length>0){ if(temp.getElementsByTagName("li")[q].childNodes[0].nodeName=="SPAN" && temp.getElementsByTagName("li")[q].getElementsByTagName("ul").length>0){ cookieArray[cookieArray.length]=(temp.getElementsByTagName("li")[q].getElementsByTagName("ul")[0].style.display=="block"); } } } // document.cookie="state="+cookieArray.join(",")+";expires="+new Date(new Date().getTime() + 365*24*60*60*1000).toGMTString(); } </script> <?php echo "<html>"; echo "<body bgcolor=\"#FFF0FF\" text=\"#000000\">"; $lines = file('./data.txt'); echo "<ul id=\"containerul\"><li>View Tree"; echo "<ul type=\"circle\"><li>Name</li>"; foreach ($lines as $line) { $text_line = explode(":" , $line); echo "<ul type=\"square\"><li>$text_line[0]</li></ul>"; } echo "<ul type=\"circle\"><li>Address</li>"; foreach ($lines as $line) { $text_line = explode(":" , $line); echo "<ul type=\"square\"><li>$text_line[1]</li></ul>"; } echo "<ul type=\"circle\"><li>Age</li>"; foreach ($lines as $line) { $text_line = explode(":" , $line); echo "<ul type=\"square\"><li>$text_line[2]</li></ul>"; } echo "<ul type=\"circle\"><li>Email</li>"; foreach ($lines as $line) { $text_line = explode(":" , $line); echo "<ul type=\"square\"><li>$text_line[3]</li></ul>"; } echo "<ul type=\"circle\"><li>Mobile</li>"; foreach ($lines as $line) { $text_line = explode(":" , $line); echo "<ul type=\"square\"><li>$text_line[4]</li></ul>"; } echo "<ul type=\"circle\"><li>Residence Number</li>"; foreach ($lines as $line) { $text_line = explode(":" , $line); echo "<ul type=\"square\"><li>$text_line[5]</li></ul>"; } echo "</ul></ul>"; ?> <script> initiate(); </script> Link to comment https://forums.phpfreaks.com/topic/60920-alignment/ Share on other sites More sharing options...
rameshfaj Posted July 20, 2007 Share Posted July 20, 2007 CAn u post the snapshot generated by that code? Link to comment https://forums.phpfreaks.com/topic/60920-alignment/#findComment-303161 Share on other sites More sharing options...
sandy1028 Posted July 20, 2007 Author Share Posted July 20, 2007 Hi, When I click on the plus image and minus image only the first value in text_line[0] gets hided and shown. Can you tell me where is the problem Link to comment https://forums.phpfreaks.com/topic/60920-alignment/#findComment-303166 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.