JavaScript - Custom Select Menu
Hello,
I am trying to make a custom select menu. Here is what I have so far: http://mikewgd.com/wp-content/portfo...custom-select/ Im just stuck at getting the <li> to become selected and etc... I am using this as reference: http://v2.easy-designs.net/articles/replaceSelect/ -- Im not using there script exactly Im doing it a different way. Im doing it more as a dropdown menu Code: <ul class="select"> <li class="selected"> cheese <ul class="drop"> <li>milk</li> <li>bread</li> <li class="selected">cheese</li> <li>pickles</li> <li>salsa</li> </ul> </li> </ul> Similar TutorialsI wanted a custom look for my list menu. Here is what I came up with... http://schrene.web44.net/List-Menu.html I created it using divs with text overflow to get the scroll bar. Here is my code Code: <div id="colorList"> <center> <div class="mySelect" onClick="myFunction()">Abalone</div> <div class="mySelect" onClick="myFunction()">Acorn</div> <div class="mySelect" onClick="myFunction()">Adobe</div> <div class="mySelect" onClick="myFunction()">Allspice</div> <div class="mySelect" onClick="myFunction()">Antarctica</div> <div class="mySelect" onClick="myFunction()">Anthracite</div> <div class="mySelect" onClick="myFunction()">Aqualite</div> <div class="mySelect" onClick="myFunction()">Arctic Blueberry</div> <div class="mySelect" onClick="myFunction()">Arctic Ice</div> <div class="mySelect" onClick="myFunction()">Arctic Lime</div> <div class="mySelect" onClick="myFunction()">Cilantro</div> <div class="mySelect" onClick="myFunction()">Cinnabar</div> <div class="mySelect" onClick="myFunction()">Clam Shell</div> <div class="mySelect" onClick="myFunction()">Clove</div> <div class="mySelect" onClick="myFunction()">Cobalt</div> <div class="mySelect" onClick="myFunction()">Cocoa Brown</div> <div class="mySelect" onClick="myFunction()">Concrete</div> <div class="mySelect" onClick="myFunction()">Copperite</div> <div class="mySelect" onClick="myFunction()">Cottage Lane</div> <div class="mySelect" onClick="myFunction()">Designer White</div> <div class="mySelect" onClick="myFunction()">Doeskin</div> <div class="mySelect" onClick="myFunction()">Dove</div> <div class="mySelect" onClick="myFunction()">Earth</div> </center> </div> It worked great but it loses the scroll bar on iPhone. I want something that works for mobile web as well as traditional.. Does anybody have any ideas how to create a list menu like this??? Any help would greatly be appreciated Hello, I'm building a simple custom dropdown menu for a web-site so that I can control look and feel as well as the behavior of an iframe. I've set it up so that when the user clicks on any of the menu's active components, an "if" sequence in the clickHandler() function is activated that gets the element's class. If the event occurred on a dropdown option, the event-target id is checked, and the appropriate function is called. At least this is how it's supposed to work. All of the drop-down options have been assigned the "dmo" class. When I test the menu and click on other elements, it works fine. But when I click the "dmo" drop-down options, nothing happens. Firebug and IE Explorer Developer Tools both show no errors, but on clicking a dropdown option, the correlate code doesn't run at all, and after hours of head-banging, I have no idea why. I need help on this one. Here's the code. 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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> BODY { background:#000; } .DropMenu { width:228px; height:1.5em; } .DropMenu span { color:#FFF; font-size:0.875em; font-family:Verdana, Geneva, sans-serif; font-weight:bold; } .DropMenuLabel { float:left; width:85px; height:1.5em; padding:0.2em 0 0 0; text-indent:0.3em; } .DropMenuTopList { width:130px; float:left; height:1.5em; padding:0 0 0 0; cursor:pointer; } .DropMenuTopList img { padding:0.4em 0 0 0.3em; cursor:pointer; } .DropMenu span { color:#FFF; font-size:.875em; font-family:Verdana, Geneva, sans-serif; font-weight:bold; vertical-align:center; } #dropMenuButton { cursor:pointer; } #dropMenuOptions { position:relative; width:130px; left:85px; padding:0.2em 0 0 0; visibility:hidden; cursor:pointer; } .MenuList { list-style-type:none; top:0; left:0; width:100%; margin:1.5em 0 0 0; padding:0; } .MenuList li{ height:1.5em; margin:0.2em 0 0 0; padding:0; width:100%; background-color:#666; border-color:#AAA; border:0.5px solid; text-indent:0.3em; } .dmo { z-index:100; } </style> <script type="text/javascript" language="javascript"> window.onload = function() { setBehavior(); } function setBehavior() { /* var downButton = document.getElementById('dropMenuButton') downButton.onclick = new Function ( "showMenu()" ); */ window.onclick = new Function ( "evt" , "clickHandler( evt )" ); } function clickHandler( evt ) { var dropMenu = document.getElementById('dropMenuOptions'); var e = evt; var targ; if (e.target) {targ = e.target} else if (e.srcElement) {targ = e.srcElement} var targClass = targ.getAttribute('class'); /* classnames dmb - dropdown button - this should toggle the dropdown visibility on and off on click, and toggle visibility on over/out dmo - option - once clicked, this should turn the dropdown visibility off */ var exclude = ("dmb" || "dmo") if (targClass != exclude ) { hideMenu() } else if (targClass == "dmb" ) { if (dropMenu.style.visibility == "visible") { hideMenu() } else showMenu(); } else if (targClass == "dmo" ) { if ( targ.id == "option1" ){ window.open(www.bing.com,"Bing") } else if ( targ.id == "option2" ){ window.open(www.bing.com,"Bing") } else if ( targ.id == "option3" ){ window.open(www.cuil.com,"Cuil") } hideMenu(); } } function showMenu() { var dropMenu = document.getElementById('dropMenuOptions'); dropMenu.style.visibility= "visible"; } function hideMenu() { var dropMenu = document.getElementById('dropMenuOptions'); dropMenu.style.visibility= "hidden"; } </script> </head> <body> <div id="customMenu" class="DropMenu"> <span> <div class="DropMenuLabel">Options:</div> <div class="DropMenuTopList dmb" id="dropMenuTopList">Temp Text <img class="dmb" id="dropMenuButton" src="Assets/Buttons/DropMenuDownButton.png"> </img> </div> <div class="dmo DropMenuOptions" id="dropMenuOptions"> <ul id="menuList" class="dmo MenuList"> <li id="option1" class="dmo">Option1</li> <li id="option2" class="dmo">Option2</li> <li id="option3" class="dmo">Option3</li> </ul> </div> </span> </div> </body> </html> Hi I have a form. In this form i have a pop down menu with 1,2,3,4,5 numbers in it. And after that i have 8 more form fields. what i want is when user select any number from pop down menu then these 8 fields should appear. for example when user select 2 from pop down menu then then these set of fields should appear twice i mean 8+8=16. and so on. my code is here 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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form id="form1" name="form1" method="post" action=""> <p> <select name="jumpMenu" id="jumpMenu"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> </p> <p> Type : <select name="jumpMenu2" id="jumpMenu2" onchange="MM_jumpMenu('parent',this,0)"> <option value="Delux">Delux</option> <option value="king">king</option> <option value="exe">exe</option> </select> </p> <p> <label>Number: <input name="textfield" type="text" id="textfield" size="5" /> </label> </p> <p> <label>Name: <input type="text" name="textfield2" id="textfield2" /> </label> </p> <p>Date Arr: <label> <input type="text" name="textfield3" id="textfield3" /> </label> </p> <p>Dep Date: <label> <input type="text" name="textfield4" id="textfield4" /> </label> </p> <p> <label> <input type="checkbox" name="checkbox" id="checkbox" /> Extra</label> </p> <p> <label> <input type="checkbox" name="checkbox2" id="checkbox2" /> Park</label> </p> <p>Remarks: <label> <textarea name="textarea" id="textarea" cols="45" rows="5"></textarea> </label> </p> </form> </body> </html> how this can be done in js Hi I wanna to have two select boxes, one of them will contain a list of provinces, and on the other I wanna have a list of cities, but based on selected province. When province selects, cities select box must be changed, too. I don't wanna use AJAX for this purpose, as the server is already too busy and I don't like to disturb it more. So if anyone can provide a solution, just by Javascript and not with AJAX, I would be appreciate it. Cheers! Hi guys, I am after a script which will has parametres to modify the select menu in webpages. I have looked at niceforms http://www.emblematiq.com/lab/niceforms/demo/ However i dont know how to apply it. Any tips would be much appreciated. George Hello all! I'm about to use this script below for a project I have. It works great but unfortunately I can't get it to read select menu (selected option) values. It returns undefined. I've asked the author but had no response as yet, so I was wondering if anyone else could see why it wouldn't read the select menu value. Code: var functionname = function () {} functionname.prototype = { options : {}, generateShortCode : function() { var content = this['options']['content']; delete this['options']['content']; var attrs = ''; jQuery.each(this['options'], function(name, value){ if (value != '') { attrs += ' ' + name + '="' + value + '"'; } }); return '[googleMap' + attrs + ']' + content + '[/googleMap]' }, sendToEditor : function(f) { var collection = jQuery(f).find("input[id^=myplugin]:not(input:checkbox),input[id^=myplugin]:checkbox:checked"); var $this = this; collection.each(function () { var name = this.name.substring(9, this.name.length-1); $this['options'][name] = this.value; }); send_to_editor(this.generateShortCode()); return false; } } var myfunction = new functionname(); I have two select menus, the second menu items should be determined based on the selected item of the first menu, and the problem I face is about using document.write() in adding the select menu items, when I write the items like this it work: Code: <select name="cities" > <script type="text/javascript"> document.write("<option value=''>city1</option>"); document.write("<option value=''>city2</option>"); document.write("<option value=''>city3</option>"); </script> </select> but when I put them in a function they wrote as a text not a menu item, and I must use a function and use if or switch in it, so what's the solution? Hi All, I searched for an answer but didn't find anything that matched my issue. I am using Dreamweaver CS5 and have a few spry validation select boxes on my page. All but one are working correctly. The one in question is spryselect1 ("spryEquipLoc"). For some reason (which I cannot figure out) this field will display the selectRequiredState even after a selection has been made. Thanks in advance for any help. Here is the code: 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> <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <script src="SpryAssets/SpryValidationSelect.js" type="text/javascript"></script> <script src="SpryAssets/SpryValidationTextarea.js" type="text/javascript"></script> <script src="javascripts/Calendar.js" type="text/javascript"></script> <!--<script src="javascripts/datetimepicker_css.js"></script>--> <script type="text/javascript"> var categories = []; categories["startList"] = ["Equipment issue","Log issue","Operator error","Media issue","Satellite issue","Program issue","Playlist issue","Promo issue"] categories["Equipment issue"] = ["Digibeta deck","XDCAM deck","Video monitor","Chyron","Switcher","Media port","Downstream keyer","Asset base PC","Device server","Rapid Play X PC","Satellite receiver","Video server","Miranda wall","Crispen automation","Vertigo X-Play"]; categories["Log issue"] = ["Log/Playlist mismatch","Log timing light","Log timing heavy","Incorrect duration","Wrong start time","Events deleted"]; categories["Operator error"] = ["Operator Name1","Operator Name2","Operator name3"]; categories["Media issue"] = ["Damaged tape","Missing media","Dublist not received","Bad media file","Snipe Issue","Bug Issue","Missing audio","Audio out of sync","Audio clipping/distorted","Audio level too low","Embedded credits"]; categories["Satellite issue"] = ["Black on air", "Signal outage", "Sun outage", "Closed captions","Audio issue","Transmitter related"]; categories["Program issue"] = ["Program light","Program heavy","Incorrect program","Incorrect material ID","Program replaced","Incorrect segment lengths","Embedded credits"]; categories["Playlist issue"] = ["Playlist light","Playlist heavy", "Incorrect playlist loaded", "Wrong playback source"]; categories["Promo issue"] = ["Incorrect material ID","Incorrect duration","Incorrect snipe","Incorrect snipe duration","Promo replaced"]; var nLists = 2; // number of select lists in the set function fillSelect(currCat,currList){ var step = Number(currList.name.replace(/\D/g,"")); for (i=step; i<nLists+1; i++) { document.forms['frmOnAirActivity']['List'+i].length = 1; document.forms['frmOnAirActivity']['List'+i].selectedIndex = 0; } var nCat = categories[currCat]; for (each in nCat) { var nOption = document.createElement('option'); var nData = document.createTextNode(nCat[each]); nOption.setAttribute('value',nCat[each]); nOption.appendChild(nData); currList.appendChild(nOption); } } function init() { fillSelect('startList',document.forms['frmOnAirActivity']['List1']) } navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false); </script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>On Air Activity Form</title> <style type="text/css"> body,td,th { font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; font-size: 14px; color: #052F47; } body { background-color: #8E8E8E; background-image: url(); background-repeat: no-repeat; } #form { behavior: url(PIE.htc); font-family: Verdana, Geneva, sans-serif; background-repeat: repeat; font-size: 14px; padding: 10px; width: 660px; border-radius: 0px 0px 20px 20px; box-shadow: #666 10px 10px 10px; border-top-style: none; border-right-style: outset; border-bottom-style: outset; border-left-style: none; background-color: #589DC6; float: right; } #wrapper { margin: auto; width: 860px; } </style> <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" /> <link href="SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css" /> <link href="SpryAssets/SpryValidationTextarea.css" rel="stylesheet" type="text/css" /> <link href="css/Calendar.css" rel="stylesheet" type="text/css" /> </head> <body> <script type="text/javascript"> // show and hide sections of a form function preparePage() { document.getElementById("List1").onclick = function() { if (document.getElementById("List1").value=="Equipment issue") { // use CSS style to show it document.getElementById("Equipment").style.display = "block"; document.getElementById("Satellites").style.display = "none"; } else if (document.getElementById("List1").value=="Satellite issue") { // use CSS style to show it document.getElementById("Satellites").style.display = "block"; document.getElementById("Equipment").style.display = "none"; } else { // hide the div document.getElementById("Equipment").style.display = "none"; document.getElementById("Satellites").style.display = "none"; } }; // now hide it on the initial page load. document.getElementById("Equipment").style.display = "none"; document.getElementById("Satellites").style.display = "none"; } window.onload = function() { preparePage(); }; </script> <div id="wrapper"> <img src="Graphics/banner.png" alt="Banner" width="860" height="84" /> <div id="form"> <form id="frmOnAirActivity" name="frmOnAirActivity" method="post" action=""> <span id="spryAirdate"> <label for="Airdate">Airdate</label><br/> <input type="Text" id="Airdate" tabindex="1" /> <img src="graphics/cal.gif" onclick="javascript:showCalendar('Airdate')" style="cursor:pointer" /> <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></p> <p> <span id="spryDiscrepType"> <label for="List1">Event Category</label><br /> <select name="List1" id="List1" tabindex="2" onchange="fillSelect(this.value,this.form['List2'])"> <option selected></option> </select> <span class="selectRequiredMsg">Please select an item.</span></span> </p> <span id="spryDiscrepSubType"> <label for="List2">Detail</label><br /> <select name="List2" id="List2" tabindex="3" onchange="fillSelect(this.value,this.form['List3'])"> <option selected></option> </select> <span class="selectRequiredMsg">Please select an item.</span></span> <p> <div id="Equipment"> <span id="spryEquipLoc"> <label for="EquipLoc">Equipment Location</label><br/> <select name="EquipLoc" id="EquipLoc" tabindex="4"> <option selected></option> <option>Master Control</option> <option>Media Services</option> <option>Central Tape</option> </select> <span class="selectRequiredMsg">Please select an item.</span></span> <p> <span id="spryEquipID"> <label for="EquipID">Equipment ID</label><br /> <input type="text" name="EquipID" id="EquipID" tabindex="5" /> <span class="textfieldRequiredMsg">A value is required.</span></span> </div> <p> <div id="Satellites"> <fieldset><legend>Affected Satellites:</legend> <table width="424"> <tr> <td width="152"><label> <input type="checkbox" name="Satellites_" value="checkbox" id="Satellites_12" /> NET Sat1</label></td> <td width="119"><label> <input type="checkbox" name="Satellites_" value="checkbox" id="Satellites_16" /> Net Sat2</label></td> <td width="137"><label> <input type="checkbox" name="Satellites_" value="checkbox" id="Satellites_20" /> Net Sat3</label></td> </tr> <tr> <td><label> <input type="checkbox" name="Satellites_" value="checkbox" id="Satellites_13" /> Net Sat4</label></td> <td><label> <input type="checkbox" name="Satellites_" value="checkbox" id="Satellites_17" /> Net Sat5</label></td> <td><label> <input type="checkbox" name="Satellites_" value="checkbox" id="Satellites_21" /> Net Sat6</label></td> </tr> <tr> <td><label> <input type="checkbox" name="Satellites_" value="checkbox" id="Satellites_14" /> Net Sat7</label></td> <td><label> <input type="checkbox" name="Satellites_" value="checkbox" id="Satellites_18" /> Net Sat8</label></td> <td><label> <input type="checkbox" name="Satellites_" value="checkbox" id="Satellites_22" /> Net Sat9</label></td> </tr> <tr> <td><label> <input type="checkbox" name="Satellites_" value="checkbox" id="Satellites_15" /> Net Sat10</label></td> <td><label> <input type="checkbox" name="Satellites_" value="checkbox" id="Satellites_19" /> Net Sat11</label></td> <td><label> <input type="checkbox" name="Satellites_" value="checkbox" id="Satellites_23" /> Net Sat12</label></td> </tr> </table> </fieldset> </div> <fieldset> <legend>Network:</legend> <table width="424"> <tr> <td width="152"> <label> <input type="checkbox" name="Network_1" value="checkbox" id="Network_1" /> Networl_1</label> </td> <td width="119"> <label> <input type="checkbox" name="Network_2" value="checkbox" id="Network_2" /> Network_2</label> </td> <td width="137"> <label> <input type="checkbox" name="Network_3" value="checkbox" id="Network_3" /> Network_3</label> </td> </tr> </table> </fieldset> <p> <label for="OnAirVariance">On Air Variance</label> <input name="OnAirVariance" type="checkbox" value="" /> <p> <span id="spryDescription"> <label for="Description">Description</label><br /> <textarea name="Description" id="Description" cols="45" rows="5" tabindex="6"></textarea> <span class="textareaRequiredMsg">A value is required.</span></span> <p> <span id="spryResolution"> <label for="Resolution">Action Taken</label><br /> <textarea name="Resolution" id="Resolution" cols="45" rows="5" tabindex="7"></textarea> <span class="textareaRequiredMsg">A value is required.</span></span></p> </form> </div> </div> <script type="text/javascript"> var sprytextfield1 = new Spry.Widget.ValidationTextField("spryAirdate", "date", {validateOn:["blur"], useCharacterMasking:true, format:"mm/dd/yyyy"}); var sprytextfield2 = new Spry.Widget.ValidationTextField("spryEquipID", "none", {validateOn:["blur"]}); var spryselect1 = new Spry.Widget.ValidationSelect("spryEquipLoc", {validateOn:["blur"]}); var spryselect2 = new Spry.Widget.ValidationSelect("spryDiscrepType", {validateOn:["blur"]}); var spryselect3 = new Spry.Widget.ValidationSelect("spryDiscrepSubType", {validateOn:["blur"]}); var sprytextarea1 = new Spry.Widget.ValidationTextarea("spryDescription", {validateOn:["blur"]}); var sprytextarea2 = new Spry.Widget.ValidationTextarea("spryResolution", {validateOn:["blur"]}); </script> </body> </html> Hello, I'm trying to populate an HTML drop down list with data from an XML file but have failed miserably so far using examples I've found. Please help. Thanks, Richard the script below should open a new window with a url specified in the select area. However, my script ignores the changes in the select area. it keeps opening the same page. I was wondering could someone take a look and tell me why? Thank you very much. <code> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> Jump Menu</title> <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> <script type="text/javascript"> function jump_menu() { var i=document.getElementById("page_select").selectedIndex; document.getElementById("jump_to_page").onclick=function() { (i==0) ? alert("Please select a page to go"):window.open("http://www."+document.getElementById("page_select").options[i].value); } } window.onload=jump_menu; </script> </head> <body> <select id="page_select"> <option>Select a Page</option> <option value="yahoo.ca">Yahoo</option> <option value="topnews.ru">Top News</option> <option value="google.com">Google</option> <option value="amazon.com">Amazon</option> </select> <button type="button" id="jump_to_page">Go</button> </body> </html> </code> hi guys! i would like to know the script for me to auto select an option in a menu on a single click. so i have two pages. on the first page is the button. second page is the drop down menu. menu has selection "fruit" "vegies" "meat". by default fruit is selected. when i click on that button it will automatically select the menu on the second page for "meat". thanks!! *Edit: I thread title should probably be "Initialize indices..."* I've done quite a bit of research but couldn't find what I need to know so here I am. I have some javascript generated by php that reads a configuration file to add options to a select menu. This is somewhat irrelevant but... these options are removed from the menu when clicked and data related to the option is shown on the page... and the option gets re-added when the data is closed. I need the option to go back in the correct place/order in the select menu... which wouldn't be a problem if I could initialize the indices of the menu's options. They need to be initialized because when the page is created, saved settings are read and certain options are not shown in the list because they may already be shown according to the settings... meaning... since browsers automatically increment the indices of the options by 1 (starting at 0), if data is closed that was initially open and therefore not in the select menu at first... the key/index associated with that data will likely not match the correct menu order. Code: <script type="text/javascript"> function addOptionToSelect(selectID,index,offset,val,txt) { var elSel = document.getElementById(selectID); elSel.options[index+offset].value = val; elSel.options[index+offset].text = txt; } function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } <?php foreach ($props as $k => $prop) { if (!in_array($prop, $_SESSION['crProps'])) { ?> addLoadEvent(addOptionToSelect('propertySelect',<?php echo $k; ?>,1,'?p=<?php echo $prop; ?>&k=<?php echo $k; ?>','<?php echo $prop; ?>')); <?php } } ?> </script> For example, suppose I have the following potential data sets: a,b,c,d,e,f In the config file that helps create the page, suppose it is something like: <Default>0:a|2:c|3:d</Default> (FYI: I've designed it so that the data set names/options are separated by the pipe character ("|") and their corresponding index is the number to the left of the colon.) Then the select menu that is initially generated would be something like: (Every other data set name except for what is already open by default.) <select id="bleh"> <option value="b">b <option value="e">e <option value="f">f </select> And by default, browsers would assign the indices like so: (skipping getElementById and all that...) select.options[0].value = b select.options[1].value = e select.options[2].value = f Whereas, I need it to be initialized like this: select.options[1].value = b select.options[4].value = e select.options[5].value = f So that when the data sets initially open are closed (a, c, or d)... they get put in the correct position in the list. I just thought of something... it's a little inefficient (OCD lol) but it should work and at worst would only cost a couple of milliseconds of processing time. A solution to this problem might be to load the menu with all options so that their indices are correct... and remove the defaults afterward. I'll try it. I am hoping you guys can help me with this issue. What I am trying to do is fairly simple, depending on what option you select in the menu I want the picture to change to different picture. The code that I posted below works perfectly except for one problem. I need the option value to display the color name, and not have the image code in it. I have researched ways to do this without having to use "value" but I just can't find one that works. Can someone please help me? Thanks in advance for any help given! Code: function changeimg(){ document.getElementById('colors').src=document.getElementById('color_dropdown_options').value } Code: <label> <select name="color" class="dropdown_options" id="color_dropdown_options" onchange="changeimg()"> <option value="/images/thumbnails/image1.jpg">White</option> <option value="/images/thumbnails/image2.jpg">Blue</option> <option value="/images/thumbnails/image3.jpg">Green</option> </select> </label> Code: <div id="display"><img src="/images/thumbnails/image1.jpg" width="270" height="382" alt="" id="colors" /> I am trying to write script that allows a user to select a new page using a select menu. But if a user changes mind and clicks Back button. i want a use to see again "Select a New Page" as a first option in the select menu. instead i see the page that was chosen before. in firefox, even when i click Refresh button, the select menu does not go back to its initial format. I tried to use the principle that each time window is loaded, the selected Index would be 0. it is not working. Could anyone give me a hint on how to fix this problem? my script is below. <html> <head> <title>Jump Menu 2</title> <script type="text/javascript"> function new_page() { var selectmenu=document.getElementById("states_form").states_select; selectmenu.onchange=function new_state() { var i=selectmenu.selectedIndex; var state=selectmenu.options[i].value; var new_page="http://www.50states.com/"+state+".htm"; location.href=new_page; window.onload=function select_reload() { i=0; } } } window.onload=new_page; </script> </head> <body> <form id="states_form"> <select name="states_select"> <option value="0"> -- Select a New State--</option> <option value="nebraska"> Nebraska</option> <option value="texas"> Texas</option> <option value="florida">Florida </option> <option value="oregon"> Oregon</option> <option value="wisconsi"> Wisconsin</option> </select> </form> </body> </html> Trying to get the divs to switch style properties when selected form select menu. Any help would be great! Code: <script type="text/javascript"> function showstuff(element){ if(document.getElementById(element).style.display = 'block') { document.getElementById(have).style.visibility="block"; document.getElementById(look).style.visibility="none"; } else if(document.getElementById(element).style.visibility = 'block') { document.getElementById(look).style.visibility="block"; document.getElementById(have).style.visibility="none"; } } </script> <select name="type" onchange="showstuff(this.value);"> <option value="look">Look</option> <option value="have">Have</option> </select> <div id="have" style="display:block;">Have</div> <div id="look" style="display:none;">Look</div> I'm tearing my hair out with this one and can't figure out why it won't work, and am hoping someone could help a Javascript noobie out. Basically, I need the script to hide two divs if one of the options in a <select> menu is selected. Here's the code I've got for the Javascript: Code: function typeoflisting() { var selectform = document.getElementById('propertytype'); if (selectform.options[selectedIndex].value == "sell") { document.getElementById('per_week').style.display = 'none'; document.getElementById('bond').style.display = 'none'; } else { document.getElementById('per_week').style.display = 'block'; document.getElementById('bond').style.display = 'block'; } } Here's the <select> form: Code: <select id="propertytype" name="propertytype" class="select" onchange="typeoflisting()"> <option value="lease">I'd like to lease a property to tenants</option> <option value="sell">I'd like to sell a property</option> <option value="share">I'd like to share a property</option> </select> And here's the first div I'm attempting to hide: Code: <div id="per_week" style="float: left;"> per week</div> And the second div I'm attempting to hide: Code: <div style="float: left; padding: 20px 20px 0px 0px;" id="bond"> <h3>Bond</h3> <input type="text" class="text" value="$"/> </div> Could anyone please tell me what I'm doing wrong? I 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 am not able to use title attribute for displaying tooltips in my browser. Now the code in http://dossett.org/11/No_onmouseover_for_options_in_IE/ implements a tooltip for multiple select drop down menu.Can you modify the code for single select Hi Guys, Im in need of some help with regards to forms. I am looking to build as basic as possible, a form that has 3 select dropdowns that have predetermined options. The user will select the first option and based on that option the second will populate and based on that, the third one will give the last option. Now, when the last one is selected, i need a div or a paragraph displaying information to be displayed. So here's the framework. Option 1 = fruit or vegitables of which fruit is selected is selected by the user Option 2 = Apples, Grapes, and pears of which apples is then selected Option 3 = Red, Green and Yellow of which Green is selected. Once green is selected, I need a description about the green aple to be displayed. Can anyone help me out on this? I am not sure where to begin and my boss is adament it must be done like yesterday. Ay help will be appreciated. Thanks. |