JavaScript - How To Change Location Of Where To Click To Expand Menu
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> Similar Tutorialsbasically i have a form with lots of fields.. drop down boxes and textarea's and standard input text.. now what i need is a way to change all of these fields with a fetch button. i can get the value for the fields from the perl script on my server side. the form basicslly sends lots of fields to my perl script and saves each field of data into seperate text docs. now my customer would like to retrieve the data back to the form to change aspects of it to be resubmitted . i am struggling with the simplist of codes to set the value of the fields from a javascript variable any ideas please. Hi, JS newbie here trying to cobble together enough to get this page done. Here's the snippet I'm having trouble with (sorry, I know it's sloppy, if you have a better way to do it by all means please post): Code: function showAdv() { if(claroxanadvanced.style.display == "none") { claroxanadvanced.style.display = "block"; claroxanoriginal.style.display = "none"; smokersformula.style.display = "none"; } else { } } function showOri() { if(claroxanoriginal.style.display == "none") { claroxanadvanced.style.display = "none"; claroxanoriginal.style.display = "block"; smokersformula.style.display = "none"; } else { } } function showSmo() { if(smokersformula.style.display == "none") { claroxanadvanced.style.display = "none"; claroxanoriginal.style.display = "none"; smokersformula.style.display = "block"; } else { } } And the page where it is implemented: http://www.claroxan.com/test/ Firefox's debug window says it might be an issue of undeclared variables - 'claroxanadvanced', 'claroxanoriginal' and 'smokersformula' are all div IDs in the html, what line should I put to declare them? Thanks 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 Hello, 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> 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. Hey guys, so i have a small problem. I have a comment area on my site. And i have the comments set to a specific height, so it only shows so much text. And i have a "read more ..." button How would i make it so that when I click the read more button. The CSS for the comment div changes to height:auto; This is what i currently have, and its not working. CSS Code: .tag_desc { clear:both; height:30px; overflow:hidden; } HTML Code: <div class="tag_read_more"><a onclick="document.getElementsByClassName('tag_desc').style.height = 'auto';">Read more ...</a></div> Thanks in advance !! Hello I need script that change link after first click for example: <a href=URL1 target=_blank><img src=....></img></a> After click on this image , URL1 changes to URL2 and visitor when click on it again and again , it goes to URL2 Regards Hello I'm a beginner when it comes to javascript. I found a nice script that did what I wanted, which was have 3 "buttons" that on hover change a different image to the side of them. However, I also would like the button that if clicked to go to a section of the website - so an internal link. I was slightly confused when reading that to have a link in javascript isn't good practice. How could I achieve this? I would really appreciate any help, thank you below is the code Code: <script language="JavaScript" type="text/JavaScript"> <!-- function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> </head> <body bgcolor="FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('information-white-alt.png','training-quote.png','training-white-alt.png','consultancy-quote.png','information-white-alt.png','information-quote.png')"> <table width="350" border="0" cellspacing="0" cellpadding="0"> <tr> <td><a href="javascript:;" onMouseOver="MM_swapImage('b1up','','information-white-alt.png','biganchor','','information-quote.png',1)" onMouseOut="MM_swapImgRestore()"><img src="information-white.png" name="b1up" width="270" height="74" border="0" id="b1up"></a></td> <td rowspan="3"><div align="center"><img src="home-statement.png" name="biganchor" width="500" height="222" id="biganchor"></div></td> </tr> <tr> <td><a href="javascript:;" onMouseOver="MM_swapImage('biganchor','','training-quote.png','b2up','','training-white-alt.png',1)" onMouseOut="MM_swapImgRestore()"><img src="training-white.png" name="b2up" width="270" height="74" border="0" id="b2up"></a></td> </tr> <tr> <td><a href="javascript:;" onMouseOver="MM_swapImage('biganchor','','consultancy-quote.png','b3up','','information-white-alt.png',1)" onMouseOut="MM_swapImgRestore()"><img src="information-white.png" name="b3up" width="270" height="74" border="0" id="b3up"></a></td> </tr> </table> I wrote a function, to change a input value to show a key, which PHP later recognizes and makes addition changes too. However I can't seem to get this simple function to work, can you see anything wrong with it? Code: function quote(id) { var shout = document.getElementById('shout'); var currentShout = '; '.shout.value; var prefix = '@'.id; shout.value = prefix.currentShout; } I call it by Code: <a href="#" onclick="javascript: quote('2');">Comment</a> the input that changes is written as Code: <input id="shout" name="shout" type="text" onKeyPress="return submitenter(this,event);"> hi master. I need some help. I need a function that change multiple images on click maybe by id Ex.: PHP Code: <table> ..... <td><img src="folder1/image1.jpg"></td> <td><img src="folder1/image2.jpg"></td> <td><img src="folder1/image3.jpg"></td> <td><img src="folder2/image1.jpg"></td> <td><img src="folder2/image2.jpg"></td> <td><img src="folder2/image3.jpg"></td> ..... </table> NOW BUTTONS (IMAGES) PHP Code: <!-- clicking this imagen will change to another button image and will change the folder1/image1.jpg and folder2/image1.jpg --> <div><img src="buttons/buton1.jpg" alt=""></div> <!-- clicking this imagen will change to another button image and will change the folder1/image2.jpg and folder2/image2.jpg --> <div><img src="buttons/buton1.jpg" alt=""></div> <div><img src="buttons/buton2.jpg" alt="click here to change only the image1.jpg in folder1, folder2 and this image"></div> <!-- clicking this imagen will change to another button image and will change the folder1/image3.jpg and folder2/image3.jpg --> <div><img src="buttons/buton3.jpg" alt="click here to change only the image1.jpg in folder1, folder2 and this image"></div> really, I don't know much about javascript, I'm waiting for your help. actually, I have loaded jquery-1.2.6.min.js Doing a project for class and we are not allowed to use any libraries. That being said, I am having a problem getting my information to appear. I have looked over my code and have no problem what the problem is. I am a novice, first real class with in depth javascript implementation and it all appears on my final assignment. What I am trying to get done is, when I click on one of the 4 images on the left column on my queue.html only those episodes of that show appear in the right column. So If I click on the Modern Family image only the 5 episdoes will appear on the right. Same for the other two. What happens with mine, is nothing. I spent all night on the code trying to get it to work and nothing is happening. Below are some of the parameters of this assignment. -*‐ The queue page is a two-column layout. Column one (left) contains a list of saved shows, and column two (right) contains a list of episodes -*‐ The queue page should use DOM scripting to update data, and at no point should a page refresh occur I think I used the wrong element somewhere, but cant for the life of me figure it out. I hope someone can point me in the right direction. http://sulley.dm.ucf.edu/~zz669709/d...nt3/queue.html - Queue Page(working on Modern Family function, other two once I get this one working) http://sulley.dm.ucf.edu/~zz669709/d...ment3/js/a3.js - Javascript(Disregard Modal Window stuff, still working on that) http://sulley.dm.ucf.edu/~zz669709/d...css/styles.css - css Thank you. Hi im using this to hide and show some text, how do i do to change the text "Show" to hide when i click it and back to "Show" when click it again. Code: <script type="text/javascript"> $(document).ready(function(){ $('.accordion-content').hide(); //toggle the componenet with class accordion $('.accordion-toggle').click(function(){ //$(this).toggleClass('toggle-accordion-active'); $(this).next('.accordion-content').slideToggle(300); }); $('#accordion-expand-all').click(function(){ $('.accordion-content').slideToggle(300); }); }); </script> Code: <p><a id="accordion-expand-all" href="#">Show</a></p> I have 4 images and these images are changing automatically with duration of 2 seconds with show hide animation. and there are 4 bullets with mentioned above 4 images. these bullets are highlighting for example if image number 1 is showing than bullet number 1 is highlighting. same thing for other 3 bullets and images please send me the code for it I want to change the color of the gridview when a button which has the value of the row index of the gridview is clicked ...this button is not inside the gridview but some where else on the form but it can send the gridview rowindex to the function so need a function to change the color of the row or bring it to focus in someway... |