Expand A Menu Option And Collapse It When Another Menu Option Is Clicked?

Sep 24, 2010

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);

[Code]....

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.

View 6 Replies


ADVERTISEMENT

Toggle Menu - Collapse And Expand All

Jan 18, 2011

I want to add a + - for collapse and expand all. I would prefer to have them change accordingly but it isn't necessary.

This is my javascript:
var toggleMenu = {
init : function(sContainerClass, sHiddenClass) {
if (!document.getElementById || !document.createTextNode) {return;} // Check for DOM support
var arrMenus = this.getElementsByClassName(document, 'ul', sContainerClass);
var arrSubMenus, oSubMenu, oLink;
for (var i = 0; i < arrMenus.length; i++) {
arrSubMenus = arrMenus[i].getElementsByTagName('ul');
for (var j = 0; j < arrSubMenus.length; j++) {
oSubMenu = arrSubMenus[j]; .....

This is my html code:
<script type="text/javascript">
function MM_showHideLayers() { //v9.0
var i,p,v,obj,args=MM_showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3)
with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible'v=='hide')?'hidden':v; }
obj.visibility=v; }
}
</script> .....

View 9 Replies View Related

How To Make A Expand And Collapse Menu

Apr 3, 2010

I want to make a menu. I did google for it. [URL]

but its too simple.

This is what I need to do.
Tab 1
Tab 2
Tab 3

By default tab 1 should be open. when I click on tab 2, tab 1 should collapse and tab 2 should expand.

View 2 Replies View Related

Expand And Collapse Of Menu With Round Corner

Mar 8, 2011

Expand and Collapse of menu with round corner with "expand image" and "collapse Image".

i have attaching a link for reference [URL]

In this in place of '+' icon replace as "expand image" as well as '-' icon

like tree menu

View 2 Replies View Related

DHTML Expand/collapse Menu Over Content?

Jul 12, 2010

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.

Collapsed
http://joylee.net/id01/processblog/images/sitemap_collapsed.gif
Expanded

[code].....

View 2 Replies View Related

Showing Divs One At A Time (expand And Collapse Menu)

Jun 5, 2009

I am developing a menu using javascript wherein, I expand and collapse divs. It works fine individually; but the problem arises when I try to hide all other divs on expanding one div. Following is the code. any change if you spot any error or even

<head>
<script>
function hideDivs(){
var arr = document.getElementsByTagName('div')

[Code]....

View 3 Replies View Related

Adding Expand / Collapse All Link To Expandable Menu?

Jan 13, 2010

I wrote my first script, which was designed for innerHTML, and tann I found a website which showed me a few things. It showed me how to use two links per harder, one shown, one hidden, and they just swap out. The final outcome allows ot to do almost any and everything I want ot to.

First and foremost, here is the script:

function veksle(id,vi){
eclipsed = document.getElementById(id+"co");
enlightened = document.getElementById(id+"ex"); if(
eclipsed.style.display == "block"){

[Code]....

I've set the menu to only allow one menu opened at a time. Thus, it is prudent to add an expand all link. I've searched all through the web and have found nothing.

View 2 Replies View Related

Expand / Collapse Paragraph With Button Clicked

Jul 14, 2009

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: [URL]
Expanded: [URL]

Here is the HTML:
<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':
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;
}

View 5 Replies View Related

Dynamic Option Menu

Jul 23, 2005

How can I make a drop down menu that are dynamically generated base on the
value selected in another drop down menu? values in both menu will need to
be from mysql query.

View 2 Replies View Related

Select Menu Option <create On The Fly>

Jul 17, 2006

I am still having trouble creating the Select Menu option. I got parts
of the correct syntax but it is still not creating the selected carrier
as an option in the parent page.

Help apprecitate,. I currently have it commented out just to show the
line to you better:

function onCarrierSelect() {
var frm = document.carrRequestForm.carrierList.selectedIndex ;
var selectCar =
document.carrRequestForm.carrierList.options[frm].text;
var varEl = "<%=varElementName%>";
if (window.opener && !window.opener.close)
var oOption = window.opener.document.createElement("OPTION");
//window.opener.form.[varEl].options.add(oOption);
oOption.innerText =selectCar;
oOption.value =selectCar;
window.close();
}

View 3 Replies View Related

Disable Option In Dropdown Menu?

Oct 19, 2007

How can I disable an option in a drop-down menu? Specifically, I want
to disable the option "Bouncy Castles". I want to display it, I just
want the user to be able to select it. As well, how can I remove the
indentation?

View 1 Replies View Related

JQuery :: Want To Disable Menu Option

Jul 19, 2009

I am using table filter.[url]...

i want to disable the Menu option...how to do this.

View 2 Replies View Related

Set Focus On A OPTION In A Select Menu

Jan 23, 2003

Hey does anyone know if it's possible to set focus on a specific option of a select menu?

View 1 Replies View Related

Select An Option From A Menu List?

Aug 23, 2010

I'm having trouble making JavaScript select an option from a list menu. I created the list menu using an array with php. I.E.

HTML Code:
<? $states = array('NY', 'NJ', 'CA');
for($s = 0; $s <= 2; $s++){?>
<option><? echo $states[$s] ?> </option>
<? } ?>

So then I have some JavaScript code, that automatically determines which state you're in. My question is, how do you get JavaScript to select the state the code has determined you're in? I tried these, to no avail.

document.form.states.value = currentstate;
document.form.states.select= currentstate;

currentstate being the variable that determines the current state you're in.

View 6 Replies View Related

Add A Selected Option To A Drop Down Menu?

Mar 10, 2010

I have a javascript adding new options to a drop down select menu getting the information from the database.[code]...

I want one of them to be added as selected. I will put an "if" check and if it the value of the option and the value in the database is equal I want that option to be added as "selected".

View 4 Replies View Related

JQuery :: ReplaceWith For An Option With A Value For A Drop Down Menu?

Mar 31, 2011

I'm trying to remove an option in a dropdown menu so it's default is not Select. I'm using jquery-latest.js.This is the html:

<tbody>
<tr>
<td class="column_main" align="center"><b>Size</b><br>[code].....

It doesn't seem to be working. When I do it without an attribute it replaces the lot of options which isn't what I'm after.

View 27 Replies View Related

JQuery :: Use It To Select And Option From A Drop Down Menu?

Apr 4, 2011

How can I do this with jquery. I tried this- code...

And it successfully added "selected" to the correct item. But it wasn't actually selected. How can I do this correctly?

View 1 Replies View Related

Changing Selected Option In Drop Down Menu?

Apr 2, 2009

Suppose I have this drop down menu: <select>
<option selected>Milk</option>
<option>Coffee</option>
<option>Tea</option>
</select>

How can I change the default (selected option) from Milk to Tea dynamically?

View 3 Replies View Related

Creating A Drop Down Option Menu For Locations?

Jun 25, 2009

I'm looking for some code for creating a drop down option menu for locations, i.e. when registering a user selects a state / county from a drop down menu.I need 3, one for USA, UK and Europe.

View 2 Replies View Related

Buttons Do Not Refresh When An Option From Drop Down Menu Changes?

Dec 4, 2011

This is hopefully my last jquery question. I have a slight issue with my buttons and dropdown menu. What happens is lets say user chooses option type "ABCDE" in first dropdown menu and then second dropdown menu chooses the value "4" for the number of answers and then clicks on the buttons "A","B","C" and "E", well if the user then decides to change the option type to "ABC", the buttons "A", "B" and "C" are still selected from the last time they have been selected.

What I want is that if the Option Type (OptionDropId) changes, then buttons selected is refreshed so no buttons are selected from the last time they have been selected.

This did used to work but when I included my change() event handler in my code which I need, the buttons do not refresh whenever a new dropdown option (OptionDropId) is selected. So I think the edit of the code may need to happen in the code below:

Code:
$(document).ready(function ()
{
var OptDrop = new Array();
OptDrop.abc = ["",1,2];

[Code]...

My code is in JSfiddle, (the second dropdown menu and buttons may not appear in JSFiddle but the code does work properly, I feel it is better displaying code in JSfiddle then in my questions as it will take up a lot of space. If you want to see working version then post code in your web document and it should work).

My Code: [click below][1]

[1]: [URL]

View 5 Replies View Related

Check Option In Select Menu Has Been Selected?

Dec 14, 2011

When a user clicks "Add To Basket" I need some javascript to check that the size option they have selected is not "-" in the form before the actual form is submitted. my form is like so:

Code:
<form method="post" name="addtobasket" action="?action=add&id=<?php echo $rows['id']; ?>">
<input type="submit" class="addtobasket" name="addtobasket" value="Add To Basket">
<select name="sizechoice">
<option disabled="disabled" value="">-</option>
<option disabled="disabled" value="S">S</option>

[Code]...

View 3 Replies View Related

New JS Vertical Menu Up - Set The Menu To Automatically Expand On Mouse Rollover Instead Of Click?

May 6, 2010

How can I set the menu to automatically expand on mouse rollover instead of click? Here is the code as it stands right now:

$(document).ready(function () {
$('img.menu_class').click(function () {
$('ul.the_menu').slideToggle('medium');
});
});

Second Question: For some reason, the menu is appearing behind a table row when it expands, thus hiding a good portion of the menu. Here it is: [URL]

Try clicking on 'Products & Services', and then clicking on "Centerfire Rifle Suppressors" from the dropdown menu. When it takes you to that category page, click the menu again and you will see that the menu hides behind the <h1> table row.

View 2 Replies View Related

JQuery :: Option That Is Similar To Mootools Image Menu?

Apr 28, 2009

URL...Anyone know of a jquery option that is similar to this mootools image menu?

View 3 Replies View Related

A Textfield Appears After An Option Is Chosen At The Dropdown Menu?

Nov 3, 2009

i'm currently designing a dropdown menu that can create a textfield or another dropdown menu based on the option from the first menu. is it possible to create this out of javascript?

Code:

<select name="dropdownMenu" id="dropdownMenu">
<option value="textfield">Show Textfield</option>
<option value="dropdown">Show Dropdown</option>
</select>

View 3 Replies View Related

Show And Hide On Select Option Dropdown Menu

Jan 30, 2009

Basically, I have written an application that runs a report based on a certain amount of parameters, one of which being date. So, the date selection is a <select></select> dropdown menu and it has the usual in it, today, yesterday, this week, last week etc. The problem is I need it to have a 'Custom' selection to run reports for custom dates. When 'Custom' is selected in the dropdown menu, two text boxes appear underneath with YYYY-MM-DD watermarked in them. I have assembled enough code from around the web to get this to work and it works fine, the problem I have is that when the user clicks off the 'Custom' option and on to a different one, I need the textboxes to disappear again.

Here is the code I am using:
<script type="text/javascript">
function showhide(divid){
thediv = document.getElementById(divid);
if(thediv.style.display== 'none' ){
thediv.style.display='block'
}else{
thediv.style.display='none'
}} .....

View 3 Replies View Related

Adding A Tooltip For Each Option Item In Drop Down Menu

Feb 3, 2011

have a scenario where I show a drop-down-with-few-items in a JSP page, to the user. The length of few options in the drop down is greater than that of the drop down's, hence our requirement is to show the hovered (not selected) option as tooltip for user's convenience. I cannot use the title attribute option as its not compatible with my web browser

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved