JavaScript - Menu Expand
Hi there guys, nive beiing a part of this forum, hope to have some help in a issue, many forums couldnt responde to me or guide me for a solution, i have a menu of a site, and i liked to when is clicked a submenu of a menu that gets expand the menu stays open. for examplo of you guys go to this site of mine
http://bonuccidesigns.cer33.com And go to link "Services", and click in a submenu named Services1, the menu Services closes...i liked to do is when i click in submenu services1 the menu services stays open, could someone help me? the code that gerantes the animation is "utils.js Hope for some help guys Be well Similar TutorialsHello, Can someone please assist me with making a script work with a 3-tier menu? http://howto.50webs.net/tutorial.php?id=165# Right now, it's only programmed for two. I need to be able to expand like this: + Item ... + Item ...... - Item ...... - Item Here it is in practice: http://golubcapital.com/relaunch/collapse-expand.php If you expand Direct Lending you'll see that Industry Verticals opens already expanded and can't be closed. Thanks in advance for any help. Christine I used the script from this website to create an expanding and collapsing sitemap bar at the bottom of my page. What I can't find is a solution to the menu expanding up over the content instead of expanding downwards. I'm wondering if it's not a javascript thing at all? ANY help is so much appreciated. Collapsed Expanded Code: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Switch menu</title> <style type="text/css"> <!-- body { text-align:center; margin:30px; } #wrapper { text-align:left; margin:0 auto; width:500px; min-height:100px; border:1px solid #ccc; padding:30px; } a { color:blue; cursor:pointer; } #myvar { border:1px solid #ccc; background:#f2f2f2; padding:20px; } --> </style> <script type="text/javascript"> <!-- function switchMenu(obj) { var el = document.getElementById(obj); if ( el.style.display != "none" ) { el.style.display = 'none'; } else { el.style.display = ''; } } //--> </script> </head> <body> <div id="wrapper"> <p><a href="http://www.dustindiaz.com/dhtml-expand-and-collapse-div-menu/" title="DHTML expand and collapse Menu">Return to "DHTML expand and collapse div menu" article"</a></p> <p><a onclick="switchMenu('myvar');" title="Switch the Menu">Switch it now</a></p> <div id="myvar"> <p>This is paragraph text that is all up in this place that does some pretty cool stuff</p> <p>This is paragraph text that is all up in this place that does some pretty cool stuff</p> <p>This is paragraph text that is all up in this place that does some pretty cool stuff</p> <p>This is paragraph text that is all up in this place that does some pretty cool stuff</p> </div> </div> </body> </html> Greetings, In a vertical expanding menu, I'm looking to change where the user clicks in order to expand the menu to the submenu. In short I want the user to be able to click on the parent menu item text and have that action expose the submenu children text items. Please see attached .png for visual. At present, the user must click on an arrow icon next to the parent menu item text to expand, but I'd also like the parent menu item to expand showing its children when clicked. All the parent menu item does right now is call in the linked page; it does not expand the menu. I've attached the .js in the 3 attached .txt files. Please let me know if there's anything else I should add/send. As far as I can tell the name of the arrow being used to expand menu can be seen in this html... <td class="wbtTdMenuItem"> <a id="menuitem1" class="wbtMenuItem wbtMenuItemSelected" href="javascript:void(0)" title="Selected Chapter: Welcome">Welcome</a> </td> <td class="wbtTdArrow" style="padding: 2px; border: 0px none;"> <a class="wbtArrowLink" title="Expand Welcome submenu" href="javascript:void(0)"> <img class="wbtArrowImg" src="images/collapse.png" alt="Expand Welcome submenu" style="width: 5px; height: 9px;"> </a> </td> Here's the html containing the name of the item I'd like to use in addition to the arrow... <td class="wbtTdSelected"> <img src="images/spacer.gif" style="width: 0px; height: 0px;" alt="Selected menu item"> </td> <td class="wbtTdMenuItem"> <a id="menuitem1" class="wbtMenuItem wbtMenuItemSelected" href="javascript:void(0)" title="Selected Chapter: Welcome">Welcome</a> </td> Hello Folks, I installed a template on the following site and did not actually write the javascript dropdown menu seen at the top of http://sthomaslc.com/ The problem is that if parent list items Ministries and Parish Leadership have enough children, they expand out right off of the screen of low resolution setups. I am totally new to javascipt programming so excuse my ignorance when I ask how to make the children items to expand out left instead of right if it's detected that the menu has hit the right side of the browser window. Best Regards David Hello all, I am currently looking to create a JavaScript menu for a website I am working on. It currently expands and collapses on click. The code in question is pasted below:- menu_status = new Array(); function showHide(theid){ if (document.getElementById) { var switch_id = document.getElementById(theid); if(menu_status[theid] != 'show') { switch_id.className = 'show'; menu_status[theid] = 'show'; }else{ switch_id.className = 'hide'; menu_status[theid] = 'hide'; } } } As you can see, it basically shows and hides the menu (when clicked). I want it to open the menu when clicked and close when another menu is opened. I have looked and have not been able to find a solution into it. Ideally I donot want it to be a long piece of code as I do have a working menu but with many more lines of JavaScript than the one I have posted. I need a solution to it urgently, your help is appreciated. Thanks Hello everyone, I am just learning the basics of javascript, and am finding myself stuck. Any help is greatly appreciated. So, I'm using the below javascript for expand / collapse text, it suffices well. However it will only collapse either table rows, or table data cells. Now, I know that these tags Code: {var trs = table.getElementsByTagName('tr'); {var a = trs[i].getElementsByTagName('td') Make the rows / data cells expand. However, I cannot seem to make it work on headers. To be lucid, I would like to know what I have to add, or edit to make the below code expand table headers (<th>), and perhaps div tags. The full javascript is thus : Code: window.onload = function() { var table = document.getElementById('stjorn'); if (table) { var trs = table.getElementsByTagName('tr'); for(var i = 0; i < trs.length; i++) { var a = trs[i].getElementsByTagName('td')[0].getElementsByTagName('a')[0]; a.onclick = function() { var span = this.parentNode.getElementsByTagName('span')[0]; span.style.display = span.style.display == 'none' ? 'block' : 'none'; this.firstChild.nodeValue = span.style.display == 'none' ? 'More' : 'Less';}; } } }; Thank you for your time. Hello forum, I need some help please. I need a javascript which hides X and shows Y if a button (text) is pressed. Needs to work on a webpage. Can someone help? Hi, Please find the attached HTML Source Code. I was able to achieve Collapsing/Expand at Project Level but not at the vendor level. However, same HTML works fine with IE 8 and FF. The Expand/Collapse at the Vendor Level fails with XHMTL Strict 1.0 and IE 7. Can any one please help? Thanks I am writing a Chrome extension script in Javascript that will expand all YUI containers on a specific website. I cannot seem to find how the onClick event is handled. Here is the webpage: https://www.lendingclub.com/browse/browse.action When you click on an item in the list, it expands to show the item details. I would like to automate this through a script but cannot figure out how to manipulate the DOM. Any help would be much appreciated. Thanks I have this Code: function showResults( results ) { if ( results.length == 0 ) { msg = "No matches found, try again"; } else if ( results.length > 1 ) { msg = "More than one match found, try again."; } else { msg = results[0]; } <div id="RESULTS" style="position: relative; width: 200px; border: solid brown 1px; background-color: wheat; height: 20px; ; overflow: visible;"> </div> when the text results are placed in the div results are cut off or overflow based on visible/hidden. can someone tell me how to make the div expand vertically with the results ? Is it possible to atchually make a javascript that onMouseOver an image expands a seperate image and also works multiple times? say from 1 px wide to 25px wide? It would be a great help if someone could help me with this one. I have the following functions: Code: <script> var timerlen = 5; var slideAniLen = 500; var timerID = new Array(); var startTime = new Array(); var obj = new Array(); var endHeight = new Array(); var moving = new Array(); var dir = new Array(); function slidedown(objname){ if(moving[objname]) return; if(document.getElementById(objname).style.display != "none") return; // cannot slide down something that is already visible moving[objname] = true; dir[objname] = "down"; startslide(objname); } function slideup(objname){ if(moving[objname]) return; if(document.getElementById(objname).style.display == "none") return; // cannot slide up something that is already hidden moving[objname] = true; dir[objname] = "up"; startslide(objname); } function startslide(objname){ obj[objname] = document.getElementById(objname); endHeight[objname] = parseInt(obj[objname].style.height); startTime[objname] = (new Date()).getTime(); if(dir[objname] == "down"){ obj[objname].style.height = "1px"; } obj[objname].style.display = "block"; timerID[objname] = setInterval('slidetick(\'' + objname + '\');',timerlen); } function slidetick(objname){ var elapsed = (new Date()).getTime() - startTime[objname]; if (elapsed > slideAniLen) endSlide(objname) else { var d =Math.round(elapsed / slideAniLen * endHeight[objname]); if(dir[objname] == "up") d = endHeight[objname] - d; obj[objname].style.height = d + "px"; } return; } function endSlide(objname){ clearInterval(timerID[objname]); if(dir[objname] == "up") obj[objname].style.display = "none"; obj[objname].style.height = endHeight[objname] + "px"; delete(moving[objname]); delete(timerID[objname]); delete(startTime[objname]); delete(endHeight[objname]); delete(obj[objname]); delete(dir[objname]); return; } </script> I have the following div tag: Code: <div id='mydiv' style='display:none'>some content</div> ....and then I have an ahref tag like so: Code: <a href="javascript:;" onclick="slidedown('mydiv');">Slide Down</a> <a href="javascript:;" onclick="slideup('mydiv');">Slide Up</a> What happens is that it just unhides real quick, and then will not work after that...it does shoot an error, which is 'Invalid argument'...and nothing else. It is craping out on the following line: obj[objname].style.height = d + "px"; not sure why...so if anyone has any insight on what I am doing wrong...please let me know. Hey guys. I've done a script where a paragraph expands when the expand button is clicked (plus.gif) and contracts when the same button is clicked again. Only problem is I want the icon to change to a minus icon (minus.gif) once it the paragraph has expanded. I'll obviously need to include this in the script, however I'm not sure how to go about it. Collapsed: Expanded: Here is the HTML: Code: <script type="text/javascript" src="expandCollapse.js"></script> <a href="javascript:void(0" onclick="return toggleMe('para2')" style="color:#ec008c"><p><img src="images/plus.gif" border="0" hspace="6" vspace="0" /></a><strong><font size="3">Beginners 2</font></strong></p> <div id="para2" style="display:none"><p>*</p> <p>Students can progress to this level upon completion of the Beginners 1. You will be taught slightly more complex pole tricks and combinations that require all the strength and agility you have gained so far. This is when you will go upside down on the pole, and how to come down gracefully!</p> <p>*</p> <p><o:p></o:p></p> <p>Cost: $220.00</p> <p>*</p> <p><o:p></o:p></p> <p>Length: 1 Hour</p> <p>*</p> <p><o:p></o:p></p> <p>Duration: 8 Weeks<o:p></o:p></p> <p><o:p>*</o:p></p></div> And here is the current javascript in 'expandCollapse.js': Code: function toggleMe(a){ var e=document.getElementById(a); if(!e)return true; if(e.style.display=="none"){ e.style.display="block" } else { e.style.display="none" } return true; } Any help much appreciated, cheers! Hi everyone I wondered if someone may help me. I downloaded a free web template that I am converting into .tpl file for a php script I use everything is going fine apart from one thing the collapse and expand script for categories in the template, it works perfectly on the template as downloaded but when it is in my .tpl files that work with the php script the collapse expand script works but the images are not displayed when you collapse then when you expand againe the expanded icon is also not displayed, as I say this works perfectly as downloaded in a .html file but not in the .tpl when running the php. Could someone take a look at the coding and tell me what maybe wrong I know nothing about Java script, PHP only a bit about html and I am pulling my hair out. Here is the Java script Bit Code: $('#wrap-categories .expanded').click(function() { if($("ul#category-menu").css("display") == 'none'){ $('#wrap-categories .expanded').css("background", "url(images/cat-expanded-icon.png) no-repeat center center"); $("ul#category-menu").show(); } else{ $('#wrap-categories .expanded').css("background", "url(images/cat-collapsed-icon.png) no-repeat center center"); $("ul#category-menu").hide(); } }); My CSS for the colapsable stuff Code: #wrap-categories .wrap-title-black .expanded{ float: left; width: 40px; height: 40px; background: url(../images/cat-expanded-icon.png) no-repeat center center; } #wrap-categories .wrap-title-black .collapsed{ float: left; width: 40px; height: 40px; background: url(../images/cat-collapsed-icon.png) no-repeat center center; } #wrap-categories .wrap-title-black .expanded:hover, #wrap-categories .wrap-title-black .collapsed:hover{ cursor: pointer; } And finaly the actual .tpl code for the colapsable bit Code: <div id="wrap-categories"> <div class="wrap-title-black"> <h2 class="nice-title">{L_276}</h2> <div class="expanded"></div> </div> <ul id="category-menu"> <!-- BEGIN cat_list --> <li><a href="browse.php?id={cat_list.ID}">{cat_list.NAME} {cat_list.CATAUCNUM}</a></li> <!-- END cat_list --> <li><a href="{SITEURL}browse.php?id=0">{L_277}</a></li> </ul> </div> I would apreciate some help and thank you in advance Hi there, I have this form whereby when there is a "File Upload Input" aka "<input id="File1" type="file" />" (I don't know the actual name, but that's not the point). The user will be able to click on "Add another attachment", which is situated below the File Upload Input. Right now, when the user clicks on it, another "File Upload Input" will appear, and will be placed below the newly-added "File Upload Input". Therefore, whenever the user clicks on the "Add another attachment", it will automatically move downwards to be situated below the newly-added "File Upload Input". How should I do it? Also, when I click on the "textbox" of the "File Upload Input", it will pop up the dialog box for me to upload my file. How can I disable it so that the user can only upload it via the "Browse" button? My code is shown as below: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Untitled Page</title> <style type="text/css"> #Select1 { width: 209px; } #Text1 { height: 143px; width: 209px; } .style17 { height: 330px; width: 427px; margin-left: 50px; } #Submit1 { margin-left: 240px; } </style> <script type="text/javascript"> var COLLAPSABLE_HELPDESK_PARENT_NAME = "collapsable_helpdesk"; var COLLAPSABLE_HELPDESK_PARENT_TYPE = "div"; var COLLAPSABLE_HELPDESK_CHILD_TYPE = "p"; var COLLAPSABLE_HELPDESK_EXPAND = "Add another attachment"; var COLLAPSABLE_HELPDESK_SHRINK = "Add another attachment"; init = function() { if(document.getElementById && document.createTextNode) { var entries = document.getElementsByTagName(COLLAPSABLE_HELPDESK_PARENT_TYPE); for(i=0;i<entries.length;i++) if (entries[i].className==COLLAPSABLE_HELPDESK_PARENT_NAME) assignCollapse(entries[i]); } } assignCollapse = function (div) { var button = document.createElement('collapse_add_attachment'); button.style.cursor='pointer'; button.setAttribute('expand', COLLAPSABLE_HELPDESK_EXPAND); button.setAttribute('shrink', COLLAPSABLE_HELPDESK_SHRINK); button.setAttribute('state', -1); button.innerHTML='dsds'; div.insertBefore(button, div.getElementsByTagName(COLLAPSABLE_HELPDESK_CHILD_TYPE)[0]); button.onclick=function(){ var state = -(1*this.getAttribute('state')); this.setAttribute('state', state); this.parentNode.getElementsByTagName(COLLAPSABLE_HELPDESK_CHILD_TYPE)[0].style.display=state==1?'none':'block'; this.innerHTML = this.getAttribute(state==1?'expand':'shrink'); }; button.onclick(); } window.onload=init; </script> </head> <body> <div class="style17"> <table cellpadding="5"> <tr> <td> Category: </td> <td> <select id="Select1" name="D1"> <option></option> </select><br /> </td> </tr> <tr> <td> Description:<br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> </td> <td> <input id="Text1" type="text" /> </td> </tr> <tr> <td> Attachment: </td> <td> <input id="File1" type="file" /> </td> </tr> </table> <div class="collapsable_helpdesk"> <p> <input id="File2" type="file" /> </p> </div> <br /> <input id="Submit1" type="submit" value="Submit" /> </div> </body> </html> Is it possible to have a thumbnail of a video, then when you click it it expands so you can watch it without having to link to a different page? I'm thinking kind of like how people link youtube videos on facebook
Hi everybody, I have this expand/contract thing, whereby a button is situated below a label "Advanced Features". And so when the user clicks on "Advanced Features", the button will drop below the whole expansion. The button should be situated BEFORE the label before clicking onto "Advanced Features". Any ideas on how I can do this? Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script language = "javascript" type = "text/javascript"> var collapsable_parent_name = "collapseExpand"; var collapsable_parent_type = "div"; var collapsable_child_type = "div"; var collapsable_expand = "Advanced Features"; var collapsable_shrink = "Simple Features"; init = function() { if(document.getElementById && document.createTextNode) { var entries = document.getElementsByTagName(collapsable_parent_type); for(i = 0; i < entries.length; i++) if (entries[i].className == collapsable_parent_name) assignCollapse(entries[i]); } } assignCollapse = function (div) { var button = document.createElement("collapse_add_adv_features"); button.style.cursor = "pointer"; button.setAttribute("expand", collapsable_expand); button.setAttribute("shrink", collapsable_shrink); button.setAttribute("state", -1); div.insertBefore(button, div.getElementsByTagName(collapsable_child_type)[0]); button.onclick=function() { var state = -(1*this.getAttribute("state")); this.setAttribute("state", state); this.parentNode.getElementsByTagName(collapsable_child_type)[0].style.display=state==1?'none':'block'; this.innerHTML = this.getAttribute(state==1?"expand":"shrink"); }; button.onclick(); } window.onload = init; </script> </head> <body> <table> <label> *First Name:</label> <input id="Text16" type="text" name="First Name" onkeydown="return noSpace(event)" /> <br /> <br /> <label> *Last Name:</label> <input id="Text17" type="text" name="Last Name" onkeydown="return noSpace(event)" /><br /> <br /> <div class="collapseExpand"> <div> <br /> <ul id="mailboxTabs" class="shadetabs"> <li><a class="selected" href="#" rel="mailbox1">1</a></li> <li><a class="" href="#" rel="mailbox2">2</a></li> <li><a class="" href="#" rel="mailbox3">3</a></li> </ul> <div class="contentBox"> <div style="display: block;" id="mailbox1" class="tabcontent"> </div> <div style="display: none;" id="mailbox2" class="tabcontent"> </div> <div style="display: none;" id="mailbox3" class="tabcontent"> </div> <div style="display: none;" id="mailbox4" class="tabcontent"> </form> </div> </div> </div> </div> </div> <script type="text/javascript"> var switchMBTabs=new ddtabcontent("mailboxTabs") switchMBTabs.setpersist(true) switchMBTabs.setselectedClassTarget("link") //"link" or "linkparent" switchMBTabs.init() </script> <input id="Submit17" type="submit" value="Submit" onclick="return check()"/> </td> </tr> </table> </body> </html> Hello, Can anyone tell me where I can find the code being used here to expand and collapse text(under the Bio section). It's exactly what I am looking for and would be much appreciated. Thanks. Hi, I want to make a list that expands and collapses like on the lynda.com site. See example http://www.lynda.com/Rhino-4-tutoria...g/59223-2.html I would also like to make it fade in and out when collapsing and expanding. I haven't been able to find a lot of information on how to do this. Would this be best using something like jQuery or just plain JavaScript? By the way I'm just starting to learn JavaScript, so any level of explanation is helpful. |