JavaScript - Several Drop Down Boxes
Hello, I have a drop down box, which display an images. It is also saved through a cookie on what option you leave it on. Is there a way you can make it so there are several drop downs on the same page that will also display images corresponding to the option chosen?
Here's a live example: www.cirula.com/options here is my coding Code: <script language="javascript"> function linkrotate(which){ var mylinks=new Array() //add in more links if you want (ie:mylinks[3]=...) mylinks[0]="http://www.google.com" mylinks[1]="http://www.ebay.com" mylinks[2]="http://www.yahoo.com" window.location=mylinks[which] } function showimage() { if (!document.images) return document.images.pictures.src= document.mygallery.picture.options[document.mygallery.picture.selectedIndex].value } </script> </head> <body onLoad="setDefaultValues()"> <div align="center"> <form name="mygallery"> <p><select name="picture" onChange="showimage(); setCookie(this.name,this.selectedIndex)" size="1"> <option value="http://www.cirula.com/images/google.png">Google</option> <option value="http://www.cirula.com/images/ebay.png">Ebay</option> <option value="http://www.cirula.com/images/yahoo.png">Yahoo</option> </select></p> </form> <p align="center"><a href="javascript:linkrotate(document.mygallery.picture.selectedIndex)" onMouseover="window.status='';return true"><img src="http://www.cirula.com/images/google.png" name="pictures" width="150" height="150" border=0></a> Similar TutorialsHi guys, i'm trying to develop a code for my sister, i would like to use javascript to finish off the following task: 1. I want to be able to select marks from 0 to 30, from 5 drop down boxes. 2. and as marks are selected, it should upgrade the total. 3. and then show me the total marks when finished. i've got up to creating the drop down boxes, now it's just adding the values once selected. Thanks! anyhelp would be welcome Hi, I'm having trouble with trying to access a selected value of a drop down menu in a table. I have menus in columns 3 and 4, named cred and grade respectively, from rows 2 onwards, and I'm using a function to access them. How do I access the value's for manipulating other variables? Here is what I have so far: Code: function f(tableID){ var len = document.getElementById(tableID).rows.length; for(var i = 1; i<len; i++){ var c = document.getElementById(tableID).rows[i].cells[2].childNodes[0]; credits = c.options[c.selectedIndex].text; } } Your help would be really appreciated Hey, so I'm a complete javascript newbie and am trying to create a drop down menu with four different boxes. The site I'm working on is basically an ecommerce site, so I'll use cars as a good example for what I want to do. Let's say that I'm selling cars and want to target the buyer directly, then I would have the following boxes, each one serving as a dependent of the one before it: 1. Pick the brand (BMW, Mercedes, Etc.) 2. Pick the type of car (Sports car, SUV, Mini Van, etc.) 3. Pick the color (blue, green, etc.) 4. Pick the price ($0-$19,999/$19,999-29,999/etc.) So far I have the first two boxes down by using the following site: http://www.supertom.com/menugen/. Now my problem is that the site only allows for the first two boxes to be made, and says that "the values in box1 are static and printed directly as normal HTML. The corresponding box2 options will also be copied into the HTML as well as the javascript for full functionality." Being a complete newbie, I have no idea what this means. So I decided to search the internet for an answer and was not able to find one, thus leading me here, which from the looks of it seems like a great forum. If anyone could tell me how to connect a third and fourth box that falls into the same hierarchy as the first and the second then I would appreciate. Really THANK YOU, and I'm really looking forward to reading your replies!! -Bobby Hi all, I'm very new to Javascript and wonder if someone can help me. I'm creating an online enrolment form for my company, who are a training company. Users enrolling on the course must make three choices - The level of course, the size of course and whether they wish to attend a workshop or study by distance learning. The combination of these three factors will determine the price. I'd like to have the price automatically calculated using javascript and displayed on the form before they submit. Can anyone give me an idea of how to do this? There are three drop down boxes for users to select their course. They a - Level of Qualification: Level 3 Level 4 Level 5 Level 6 Scale of Qualification: Award Certificate Diploma Preferred Delivery Method Workshop Distance Learning Each possible combination of these will affect the price. So for instance, if the user were to select 'Level 4', 'Certificate' and 'Workshop' the price would be calculated based on these three options. How can I calculate the ultimate price and then display it on the page (I was thinking of using innerHTML in a 'span' element to display the final value, but if anyone has any better ideas I'd be glad to hear them) The HTML code for the drop down boxes is below: Code: <form action="enrolment.php" method="post"> <select name="level" class="input" id="level"> <option value="chooselevel"></option> <option value="Level 3">Level 3</option> <option value="Level 4">Level 4</option> <option value="Level 5">Level 5</option> <option value="Level 6">Level 6</option> </select> <select name="size" class="input" id="size"> <option value="choosesize"></option> <option value="Award">Award</option> <option value="Certificate">Certificate</option> <option value="Diploma">Diploma</option> </select> <select name="delivery" class="input" id="deliv"> <option value="deliverymethod"></option> <option value="Workshop">Workshop</option> <option value="Distance Learning">Distance Learning</option> </select> </form> Thanks all, hope someone here can help! Regards Chris *EDIT: I should mention that the form is also inside a table - Not sure if that will make a difference. I have been searching for a long time but have been unsuccessful on how to develop a drop down menu but have the menu items show in a list above the main nav. Not below. I really like the way this functions: http://www.sohtanaka.com/web-design/examples/toggle/ But I would like the item in the list to appear above the main nav so it animates up not down. Can anyone help me on how to alter this js code to perform this task? Here is the jQuery file link: http://code.jquery.com/jquery-latest.js I tried going through this js file but it very complex. Can anyone tell me what I need to change to have the animation roll up instead of down? Any help would be most appreciated. Hello everyone! So, what it does: You can successfully drag something anywhere, but when you click it again, it resets to its original position (I don't know why), and when you try to drag it again, as soon as your cursor touches the object it disappears (I don't know why). I'm hoping someone can tell me why it is happening and how to fix it! Code: // JavaScript Document var posX; var posY; var element; function drag(event) { element = document.getElementById("square"); posX = event.clientX; posY = event.clientY; element.addEventListener("mousemove", move, false); } function move(event) { if (typeof(document.getElementById("square").mouseup) == "undefined") element.addEventListener("mouseup", drop, false); //Prevents redundantly adding the same event handler repeatedly element.style.left = event.clientX - posX + "px"; element.style.top = event.clientY - posY + "px"; } function drop() { element.removeEventListener("mousemove", move, false); element.removeEventListener("mouseup", drop, false); } the html is a simple (position is set to relative): <p id="square" onmousedown="drag(event)">meep</p> Lastly, and most importantly, thank you all for your time =] EDIT: This is the first time I've written javascript code and would like to learn the basics, which is why I am not using a library. Hi, I've been searching for a good tut on modal boxs for a while where they open in middle of screen like facebook boxs & i want to have one where you use onClick function from href link. example: <a href="#" onclick="'files/delete.php?postId=$post['id']','modal_box'">Delete</a> and so on with other things. Can anyone help. Thanks. ok i have to selection boxes and they need to read each other and input either a yes or a no into a text form i would really appreciate some help thanks heres what i have if it helps Code: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" /> <title>Galvanic Corrosion Chart</title> </head> <body> <br /> <form name="gcc"> <div align="center"><a href="website.html"><img style="border: 0px solid ; width: 278px; height: 50px;" alt="" src="pics/LOGO.png" border="0" height="50" width="278" /></a><br /> </div> <p style="text-align: center;" align="center"><font size="+2"><span style="font-family: Century Gothic;"><font style="text-decoration: underline;" size="+3"> <font face="Futura Bk BT">Galvanic Corrosion Chart<span style="text-decoration: underline;"><span style="text-decoration: underline;"><span style="text-decoration: underline;"><span style="text-decoration: underline;"><span style="text-decoration: underline;" /></span></span></span></span></font></font></span></font><font face="Futura Bk BT"><br /> </font> </p> <br /> <table style="text-align: left; margin-left: auto; margin-right: auto;" height="119" width="610"> <tbody> <tr> <td style="vertical-align: top; text-align: center;" align="center" valign="middle"><font face="Futura Bk BT"><font size="+1"> <font size="+1"> Material 1</font></font><br /> <select name="mat1"> <option>Zinc Plating</option> <option>Zinc Die Casting</option> <option>Galvanize</option> <option>Tin-Zinc</option> <option>Cadmium-Zinc Solder</option> <option>Aluminum(Clad.1100.3003.5052.6160)</option> <option>Cadmium Plate</option> <option>Aluminum Castings</option> <option>Carbon & Alloy Steel, Cast Iron</option> <option>Aluminum(2024.2017.7075)</option> <option>Lead</option> <option>Lead-Silver Solder</option> <option>Tin-Lead Solder</option> <option>Tin Plating</option> <option>Chromium Plate</option> <option>Stainless 18/2</option> <option>Copper & Alloys</option> <option>Stainless 18/8</option> <option>Silver Solder</option> <option>Monel</option> <option>Nickel Plate</option> <option>Titanium</option> <option>Silver Plate</option> </select> <br /> </font></td> <td colspan="1" rowspan="1" style="vertical-align: top; text-align: center;" valign="middle"><font face="Futura Bk BT"><font size="+1"> Material 2</font><br /> </font> <select name="mat2"> <option>Zinc Plating</option> <option>Zinc Die Casting</option> <option>Galvanize</option> <option>Tin-Zinc</option> <option>Cadmium-Zinc Solder</option> <option>Aluminum(Clad.1100.3003.5052.6160)</option> <option>Cadmium Plate</option> <option>Aluminum Castings</option> <option>Carbon & Alloy Steel, Cast Iron</option> <option>Aluminum(2024.2017.7075)</option> <option>Lead</option> <option>Lead-Silver Solder</option> <option>Tin-Lead Solder</option> <option>Tin Plating</option> <option>Chromium Plate</option> <option>Stainless 18/2</option> <option>Copper & Alloys</option> <option>Stainless 18/8</option> <option>Silver Solder</option> <option>Monel</option> <option>Nickel Plate</option> <option>Titanium</option> <option>Silver Plate</option> </select> </td> </tr> <tr> <td colspan="2" rowspan="1" align="center" valign="top"><font face="Futura Bk BT" size="+1">Acceptable</font><br /> <font face="Futura Bk BT"><input name="AR" readonly="readonly" /></font></td> </tr> </tbody> </table> </form> </body> </html> Ok I know there are a few other posts about this but I can't find one similar to my problem. The confirmation box pops up, but cancel does nothing. it is for deletion of a movie off a server for class, but if you hit cancel it deletes the entry anyway. here is my code: Code: <script type="text/javascript"> function show_confirm() { var r=confirm("Are you sure you want to delete?"); if (r==true) { window.location="movie_delete.cfm?FilmID=#FilmID#"; } } </script> [<a href="movie_delete.cfm?FilmID=#FilmID#" onclick="show_confirm()">Delete</a>] notice anything wrong? Hi Can anyone help with this.... I'm trying to create and object that has text on either side of the flip boxes and when the correct answers are showing (some will need to be flipped and some not). The boxes are disapled and a message appears to say this is correct. I need to work out how to write different text on the other side of each flip box How to differentiate between when the box is flipped and when it isnt (to assign a value) How to disable boxes when all are correct or how to add a subit button so that when users think the boxes are correct they click to check answers So far I have this and now im stuck, its not doing exactly what i want. I'm new to all this and just need a bit of guidance... Code: <style> .content { width: 880px; height:180px; } .test { width:800 height:100 } .answers{ position:absolute; width:25px; height:20px; left: 200px; top: 4px; } .correct{ background-repeat:no-repeat; background-image:url(assets/correct-small.png); z-index:1; } .incorrect{ background-repeat:no-repeat; background-image:url(assets/incorrect-small.png); z-index:1; } .flip { position:relative; float:left; margin-left:3px; margin-right:3px; width: 500px; height: 22px; padding: 3px; margin-bottom: 2px; border: 1px #CCC solid; background-color: #EFEFEF; text-align: center; } .flip:hover{ cursor: pointer; background-color: #FFF; } </style> <script language="javascript"> trueCount = 0; falseCount = 0; for(i=1;i<=15;i++) { $("#flipbox" + i).click(function(){ $(this).flip({ direction:'tb', color: '#EFEFEF', }); }); } function addAnswer(div, answer){ if($("#"+div).hasClass("correct")) { trueCount--; $("#"+div).removeClass("correct"); } else { $("#"+div).addClass("correct"); answersArray[trueCount] = $("#"+div).parent().html().substr(0, $("#"+div).parent().html().indexOf('<')); trueCount++; if(trueCount == 2) { $(".test").fadeOut(1000, function(){ $(this).html("<h3>Correct - </h3>" ).fadeIn(1000); }) } } } updateBookmark(); </script> <br /><br /> <div class="content"> <div class="flip" onclick="addAnswer('answer1','c')" id="flipbox1">Reading a book<div class="answers" id="answer1"></div></div> <div class="flip" onclick="addAnswer('answer2','t')" id="flipbox2">Position their body so that they are facing you <div class="answers" id="answer2"></div></div> <div class="flip" onclick="addAnswer('answer3','c')" id="flipbox3">Talk<div class="answers" id="answer3"></div></div> <div class="flip" onclick="addAnswer('answer4','t')" id="flipbox4">Make eye contact<div class="answers" id="answer4"></div></div> <div class="flip" onclick="addAnswer('answer5','c')" id="flipbox5">Ask questions<div class="answers" id="answer5"></div></div> </div> <div class="test"></div> Ok, this HAS to be some stupid typo I can't find somewhere or something but I don't see where. Basically the alertbox works just fine when only the show_alert() function and the button calling it are in the code. But neither work if only the alert() function and the button calling that are in the code, nor does it work by itself. However I see no differences in how they are coded unless I am missing something very very simple. Code: <html> <head> <script type="text/javascript"> function show_alert() { alert("I am an alert box!"); } function alert() { alert("again"); } </script> </head> <body> <input type="button" onClick="show_alert()" value="Show alert box" /> <input type="button" onClick="alert()" value="CLICK me" /> </body> </html> I am stuck on this question. 1. To set the value contained in a field such as an input box, you must use the ____________________ property. This is based on Javascript. What type of properties are used for fields in an input box? Thanks I've looked all over google but can't seem to find this out. How do you make it so you have 2 text boxes beside each other where you type (for example) 1 character in the first, and it flows into the next (without the need for pressing tab or whatever) I'm talking about the sort of thing you get when entering a software key Is there a way add another dropdown form to this script? http://javascript.internet.com/navig...-comboxes.html Or do you happen to have another script that does the same job? I need three level connected dropdown boxes. Each one should be filtered according to previous selection and should be empty before that selection is made... Thanks in advance... Hi, I'm a javascript noob, and I am doing a project for CS. I got the page to look how it is supposed to, but it does not work correctly. The input boxes should display a number between 1-4 in the output boxes, but the box displays [object HTMLInputElement] instead. And the buttons all perform their task to one output box, not their own output box. Sorry if that was confusing. Please take a look. <html> <!-- esp.html Nick Bravante --> <!-- C --> <!-- ======================= --> <head> <center> <title> <h1> ESP Tester </h1> </title> <script type="text/javascript" src="http://dave-reed.com/book/random.js"> </script> <script type="text/javascript"> function PickNumber() // Results: displays a random number in messageBox { var number; number = RandomInt(1, 4); document.getElementById('messageBox').value= "You guessed " + guessOne + " My number was " + number + "."; } </script> </head> </br> <body> Enter your Guess(1-4).<input type="num" id="guessOne" size="4" value="" /> </body> <body> <p style="text-aign:center"> <input type="button" value="Guess 1" onclick="PickNumber();" /> <br /> <input type="text" id="messageBox" size="90" /> </p> </body> <head> <center> <title> <h1> ESP Tester </h1> </title> <script type="text/javascript" src="http://dave-reed.com/book/random.js"> </script> <script type="text/javascript"> function PickNumber() // Results: displays a random number in messageBoxTwo { var number; numberTwo = RandomInt(1, 4); document.getElementById('messageBoxTwo').value= "You guessed " + guessTwo + " My number was " + numberTwo + "."; } </script> </head> <head> <center> <title> <h1> ESP Tester </h1> </title> <script type="text/javascript" src="http://dave-reed.com/book/random.js"> </script> <script type="text/javascript"> function PickNumber() // Results: displays a random number in messageBox { var number; numberThree = RandomInt(1, 4); document.getElementById('messageBox').value= "You guessed " + guess + " My number was " + numberThree + "."; } </script> </head> </br> <body> Enter your Guess(1-4).<input type="num" id="guessTwo" size="4" value="" /> </body> <body> <p style="text-aign:center"> <input type="button" value="Guess 2" onclick="PickNumber();" /> <br /> <input type="text" id="messageBoxTwo" size="90" /> </p> </body> </br> <body> Enter your Guess(1-4).<input type="num" id="guessThree" size="4" value="" /> </body> <body> <p style="text-aign:center"> <input type="button" value="Guess 3" onclick="PickNumber();" /> <br /> <input type="text" id="messageBoxThree" size="90" /> </p> </body> <head> <center> <title> <h1> ESP Tester </h1> </title> <script type="text/javascript" src="http://dave-reed.com/book/random.js"> </script> <script type="text/javascript"> function PickNumber() // Results: displays a random number in messageBox { var number; numberFour = RandomInt(1, 4); document.getElementById('messageBoxFour').value= "You guessed " + guessFour + " My number was " + numberFour + "."; } </script> </head> </br> <body> Enter your Guess(1-4).<input type="num" id="guessFour" size="4" value="" /> </body> <body> <p style="text-aign:center"> <input type="button" value="Guess 4" onclick="PickNumber();" /> <br /> <input type="text" id="messageBoxFour" size="90" /> </p> </body> </html> Hi, I have a drop down menu, which you select an item and the text in a text box below displays according to what has been chosen from the drop down list. I have too much text in some case to appear in the text box, so i wanted to find some code so i can select different numbers for pages so i can display the information on different pages. Is this possible. Thanks I would like to create collapsing boxes. I would like for them to have different colors. Box1 Box 3 Link 1 Link 1 Link 2 link 2 Link 3 Link 3 Box2 Box 4 Link 1 Link 1 Link 2 link 2 Link 3 Link 3 I got the code to do the first column (box 1 and 2). But I don't know how to add a second column (box 3 and 4). Any help would be appreciated. Thanks In a form I have two input boxes (ids of return1 and return2) with default values of 0 and a span element (id return3). The span's value is initalized to 0 on page load, and it updates when a button is clicked that calculates x - value of return1 - value of return 2, where x is calculated elsewhere. Form code: Code: Month 1: <input size="7" type="text" value="0" id="return1" name="return_1"> <input type="button" value="Calculate Remaining Amount" onClick="thirdReturn();"> Month 2: <input size="7" type="text" id="return2" value="0" name="return_2"> Month 3: <span style="color:black; font-size:14px;" id="return3"></span> ThirdReturn code: Code: function thirdReturn() { var first_return = document.getElementById("return1").value; var second_return = document.getElementById("return2").value; first_return = first_return.replace(/\,/g,''); second_return = second_return.replace(/\,/g,''); var combined = Number(first_return) + Number(second_return); if (typeof this.remaining_pipp_amount == "undefined") { alert('Please select a Flex option'); } else{ if (combined > this.remaining_pipp_amount){ alert('Return Amount Exceeds Credit Amount'); } else{ var temp = this.remaining_pipp_amount - combined; var third_return_amount = document.getElementById("return3"); third_return_amount.innerHTML = addCommas(Math.round(temp)); } } } I am trying to change it so that if return2 is zero when the button is clicked, return2 = x - return 1. Here is what I have: Code: function thirdReturn() { var first_return = document.getElementById("return1").value; var second_return = document.getElementById("return2").value; first_return = first_return.replace(/\,/g,''); second_return = second_return.replace(/\,/g,''); var combined = Number(first_return) + Number(second_return); if (typeof this.remaining_pipp_amount == "undefined") { alert('Please select a Flex option'); } else{ if (combined > this.remaining_pipp_amount){ alert('Return Amount Exceeds Credit Amount'); } else{ var temp = this.remaining_pipp_amount - combined; if (second_return == 0){ var new_second = document.getElementById("return2") new_second.innerHTML = Math.round(temp); } else{ var third_return_amount = document.getElementById("return3"); //alert (temp); third_return_amount.innerHTML = addCommas(Math.round(temp)); } } } } Does anyone know why this doesn't work or what can be done to fix it? Thank you! I want to make a chat-box so people can log in under a nickname and talk to eachother, anyone have any idea how i can go about doing this?
|