JavaScript - Z-index Issue (javascript) Need Help Please!
I am trying to "swap" the contents of a div(#right_top) depending on which line item you hover over. Awkward, but does work, but.... the problem is that although I can get the code to work, the "right_top" div gets longer (physically on the page) even though each div is supposed to be a different "z-index". I don't know how to correct this, or is there better code? I would appreciate any help! Thank you. Complete code 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> <script language="javascript" type="text/javascript"> <!-- Hide script from older browsers function MM_findObj(n, d) { //v4.0 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 && document.getElementById) x=document.getElementById(n); return x; } function MM_showHideLayers() { //v3.0 var i,p,v,obj,args=MM_showHideLayers.arguments; for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(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> <!-------------------------------------------------------------> <style type="text/css"> #wrapper{ width:800px; } #left_top{ background-color:#66FFFF; width:270px; padding-top:60px; padding-left:30px; float:left; } #right_top{ background-color:#66FF33; padding-top:60px; width:480px; padding-left:20px; float:left; } #first_div{ position:relative; width:450px; height:300px; z-index:1; visibility: hidden; left:0px; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; color:#FFFFFF; } #second_div{ position:relative; font-size:16px; width:450px; height:300px; z-index:2; top: -320px; visibility: hidden; left:0px; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; color:#FFFFFF; } #third_div{ position:relative; font-size:16px; width:450px; height:300px; z-index:3; top: -640px; visibility: hidden; left:0px; font-family:Verdana, Arial, Helvetica, sans-serif; font-style:italic; color:#FFFFFF; } </style> </head> <body> <div id="wrapper"> <div id="left_top"> <table width="210" height="483"> <tr><td width="210" height="477" valign="top"> <div><a title="first div" href="#" class="style1" onClick="return false" onMouseOver="MM_showHideLayers('Initial','','hide','first_div','','show')" onMouseOut="MM_showHideLayers('Initial','','show','first_div','','hide')">show first div</a></div> <div><a title="second div" href="#" class="style1" onClick="return false" onMouseOver="MM_showHideLayers('Initial','','hide','second_div','','show')" onMouseOut="MM_showHideLayers('Initial','','show','second_div','','hide')">show second div</a></div> <div><a title="third div" href="#" class="style1" onClick="return false" onMouseOver="MM_showHideLayers('Initial','','hide','third_div','','show')" onMouseOut="MM_showHideLayers('Initial','','show','third_div','','hide')">show third div</a></div> </td></tr> </table> </div><!-- end of left_top --> <div id="right_top"> <div id="first_div"> <p align="justify"><b>first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first first </b></p></div> <div id="second_div"> <p align="justify"><b>second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second second </b></p></div> <div id="third_div"> <p align="justify"><b>third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third third </b></p></div> </div><!-- end of right_top div --> </div><!-- end of wrapper --> </body> </html> Similar TutorialsHi, I am very new to Javascript but have found a great tutorial to create a dynamic dropdown menu. I got it to work, but have problems redirecting it to the correct page after the necessary page refresh to load the items in the 2nd dropdown menu. The Javascript in the header is the following: Code: <SCRIPT language=JavaScript> function reload(form){ var val=form.cat.options[form.cat.options.selectedIndex].value; self.location='index.php?cat=' + val ;} </script> My PHP controller (index.php) code to load the correct frames is as follows: Code: <ul id="navbar"> <li><a href="index.php?id=home">Home</a></li> <li><a href="index.php?id=overview">Overview</a></li> <li><a href="index.php?id=add">Add new product</a></li> </ul> Code: if(isset($_GET['cat'])){ include ('add.html.php');} else { switch($_GET['id']) { default: include('home.html.php'); break; case "home": include('home.html.php'); break; case "overview": include('add.html.php'); break; case "add": include('add.html.php'); } } So I have made a workaround to load the "add.html.php" frame with the if(isset)$_GET['cat']. But what I really would like to do is to change the Javascript self.location to Code: self.location='index.php?id=add?cat=' + val ;} so that the PHP index script loads the add.html.php automatically. However, when changing the self.location as described above the page is redirected to home.html.php. It is really annoying, I have googled for a full day but haven't found a solution yet. Maybe someone can tell me how I can easily load the correct frame by using Javascript? Many thanks in advance!! Hello All! First I would like to say that I have attempted to find an answer to my issue and there is obviously an enormous amount of help across this and other forums regarding how to use Javascript to modify your CSS styles including changing the z-Index property. I am to the point where I believe maybe it just needs an extra set of eyes to help me understand what I am doing wrong here! My dilemma is that I have a table on my site which has four images, one for different areas of the site. Below that table area, I have a space where I plan to display the text describing those sections upon mouse rollover. My goal is to have an outer div tag with position relative and then contain 4 div tags inside of that with position absolute so that I can stack them under the background all with negative z-Indexes. I have a javascript that is called on mouse over and mouse out to raise the z-Index of each div text area, but it is not working. See the code below: Javascript for the z-Index change: Code: <script type="text/javascript"> <!-- //function to change zIndex function swapMyImages(obj,z){ var theObj; //ie4 if(document.all){ theObj=document.all(obj); theObj.style.zIndex=z; } //ie5,6, Mozilla 1.0 and Opera 6 if(document.getElementById){ theObj=document.getElementById(obj); theObj.style.zIndex=z; } //nn4x if(document.layers){ theObj=document.layers[obj]; theObj.zIndex=z; } } //--> </script> </head> Anchor for one of the images with mouse overs attached: Code: <a class="thumb" href="..." title="Visit Our Shop" onmouseover="swapMyImages('shoptext','10')" onmouseout="swapMyImages('shoptext','-10')"><img src="images/hometable_back.jpg" width="190" alt="Tee Shirt Shop" longdesc="..." /></a> my Div section with the text areas set to negative z-Index: Code: <div id="hometext"> <div id="servicetext">service text here</div> <div id="shoptext">shop text here</div> <div id="portfoliotext">[portfolio text here</div> <div id="contacttext">contact text here</div> </div> my style sheet items for the divs: Code: .hometext { position:relative; float: none; left:0px; top:0px; text-align:center; z-index:-10; } #servicetext { position:absolute; float: none; left:0px; top:0px; text-align:center; z-index:-10; background-color:#000000; } #shoptext { position:absolute; float: none; left:0px; top:0px; text-align:center; z-index:-10; background-color:#000000; } #portfoliotext { position:absolute; float: none; left:0px; top:0px; text-align:center; z-index:-10; background-color:#000000; } #contacttext { position:absolute; float: none; left:0px; top:0px; text-align:center; z-index:-10; background-color:#000000; } I tried posting the code but it's too long... Page address: http://professorcuddlecore.com/paintings/ Problem: Click first or second photo, pops up fine, bottom text is behind the photo. You can view the JS by viewing source etc, sorry I can't fit it here. I spent 2-3 hours trying to figure out the problem but I'm new to JS and it looks like pretty convoluted code I'm using (obviously didn't write it myself, it's by "PopBox.") Thanks for any time spent helping me, pre-appreciated. I am using the below script on http://bubbles4urtroubles.com. Because I made the bubbles larger than the ones used in the original script, the horizontal scroll bar displays some of the time, then turns off. Is there any way to just not have the horizontal scroll bar? Also, how would I set the zindex so the bubbles are always in front of everything else. Thank you in advance. //Bubble Script by Lisa (issa@lissaexplains.com, http://lissaexplains.com) //Based on code by Altan d.o.o. (snow@altan.hr) //For full source code and installation instructions to this script, visit http://www.dynamicdrive.com var no = 15; // image number or falling rate var speed = 2; // the lower the number the faster the image moves var snow = new Array(); snow[0] = "bubble.png" snow[1] = "bubble2.png" snow[2] = "bubble3.png" var ns4up = (document.layers) ? 1 : 0; // browser sniffer var ie4up = (document.all) ? 1 : 0; var ns6up = (document.getElementById&&!document.all) ? 1 : 0; var dx, xp, yp; // coordinate and position variables var am, stx, sty; // amplitude and step variables var i, doc_width = 600, doc_height = 1024; if (ns4up||ns6up) { doc_width = self.innerWidth; doc_height = self.innerHeight; } else if (ie4up) { doc_width = document.body.clientWidth; doc_height = document.body.clientHeight; } dx = new Array(); xp = new Array(); yp = new Array(); am = new Array(); stx = new Array(); sty = new Array(); j = 0; for (i = 0; i < no; ++ i) { dx[i] = 0; // set coordinate variables xp[i] = Math.random()*(doc_width-50); // set position variables yp[i] = Math.random()*doc_height; am[i] = Math.random()*20; // set amplitude variables stx[i] = 0.02 + Math.random()/10; // set step variables sty[i] = 0.7 + Math.random(); // set step variables if (ns4up) { // set layers if (i == 0) { document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src=\""+ snow[j] + "\" border=\"0\"></layer>"); } else { document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src=\""+ snow[j] + "\" border=\"0\"></layer>"); } } else if (ie4up||ns6up) { if (i == 0) { document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"VISIBILITY: visible; TOP: 15px; LEFT: 15px; width:1;\"><img src=\"" + snow[j] + "\" border=\"0\"></div>"); } else { document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"VISIBILITY: visible; TOP: 15px; LEFT: 15px; width:1;\"><img src=\"" + snow[j] + "\" border=\"0\"></div>"); } } if (j == (snow.length-1)) { j = 0; } else { j += 1; } } function snowNS() { // Netscape main animation function for (i = 0; i < no; ++ i) { // iterate for every dot yp[i] -= sty[i]; if (yp[i] < -50) { xp[i] = Math.random()*(doc_width-am[i]-30); yp[i] = doc_height; stx[i] = 0.02 + Math.random()/10; sty[i] = 0.7 + Math.random(); doc_width = self.innerWidth; doc_height = self.innerHeight; } dx[i] += stx[i]; document.layers["dot"+i].top = yp[i]+pageYOffset; document.layers["dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]); } setTimeout("snowNS()", speed); } function snowIE_NS6() { // IE main animation function for (i = 0; i < no; ++ i) { // iterate for every dot yp[i] -= sty[i]; if (yp[i] < -50) { xp[i] = Math.random()*(doc_width-am[i]-30); yp[i] = doc_height; stx[i] = 0.02 + Math.random()/10; sty[i] = 0.7 + Math.random(); doc_width = ns6up?window.innerWidth-5:document.body.clientWidth; doc_height = ns6up?window.innerHeight-5:document.body.clientHeight; } dx[i] += stx[i]; if (ie4up){ document.all["dot"+i].style.pixelTop = yp[i]+document.body.scrollTop; document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]); } else if (ns6up){ document.getElementById("dot"+i).style.top=yp[i]+pageYOffset+'px'; document.getElementById("dot"+i).style.left=xp[i] + am[i]*Math.sin(dx[i])+'px'; } } setTimeout("snowIE_NS6()", speed); } if (ns4up) { snowNS(); } else if (ie4up||ns6up) { snowIE_NS6(); } // End --> </script> Hi folks! I know this is a really simple script, but I'm still a beginner, still learning and struggling..haha thanks for sticking with me Anyway my aim here is to have x,y, or z Div come to the front onClick. I've figured out how to do it with two Div's (using the code below) but not with 3 or more. I'm not attached to the code, so if you want to suggest something totally different I am all ears! Thank you greatly! ian Code: <script> function changeZunder() { layer1.style.zIndex = 1; layer2.style.zIndex = 2; } function changeZover() { layer1.style.zIndex = 2; layer2.style.zIndex = 1; } </script> ---- <body> <div id="layer1" style="z-index: 1; position: absolute;" onClick="changeZover()"> FIRST BOX </div> <div id="layer2" style="z-index: 1; position: absolute;" onClick="changeZunder()"> SECOND BOX </div> </body> Happy Star Wars Day! Hopefully someone is strong in the force and can help. I have a HTML form and I need to get the user to select one of 350 options. I have broken down the options into "Major Group", "Sub-Major Group", "Minor Group" and "Unit" I'm looking to create 4 dynamically changing drop down lists to point the user to their final choice. All 350 options are in one database table with the following headings: [Major Group][Major Group Title][SubMajor Group][SubMajor Group Title][Minor Group][Minor Group Title][Unit][Unit Title] The 'groups' are numeric, and the title's alphanumeric. I have used the MySQL database to achieve this as it makes it easier to update the 350 options in the future should I need to. As far as the tutorial over at W3Schools.com has advised I need to use the following process: HTML Form - <Select> onclick run Javascript function Javascript function connects to server via PHP PHP runs query on the MySQL database and returns results Javascript then populates the 2nd drop down. and so on through to the final drop down. There are never more than 9 options in each drop down. Please can someone help me set this up. I have been using the code examples from W3Schools.com to put the following together. I use the alerts to check it's progress. It seems to be getting stuck when checking that the "if (xmlhttp.readystate==4)" line. Using Safari's built in Debug console the error I get back is that the php file cannot be found and there is a "500 Internal Server Error" - although I think (read as: assume) this is because the "if (xmlhttp.readystate==4)" isn't working. Any help would be much appreciated. Code: function selectMajor(str) { // an alert box to show that both a value has passed and it is the right type alert(SOC_Major.value); // enable the next drop down - SOC_SubMajor document.getElementById('SOC_SubMajor').disabled=false; // clear the next select box? document.Add_Vacancy.SOC_SubMajor.options.length=0 // POST to the php script // AJAX goes here if (str=="") { document.getElementById('SOC_SubMajor').innerHTML=" "; alert("str is empty"); return; } if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, opera, Safari xmlhttp=new XMLHttpRequest(); alert("new XMLHttpRequest created"); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject('Microsoft.XMLHTTP'); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readystate==4) { alert("xmlhttp.readystate = 4"); if(xmlhttp.status==200) { alert("xmlhttp.status = 200") document.getElementById('SOC_SubMajor').innerHTML=xmlhttp.responseText; } else { alert("There was a problem while using XMLHTTP:\n"); } } } xmlhttp.open("POST","scripts/SOCSubMajorSelect.php?q="+str,true); xmlhttp.send(); } Hey everyone, I've got this slight problem with my code in javascript and I cant solve it to save my life and I don't really want to mess more things around incase it makes it worse. For some reason, when I click "get age" it just doesnt run, but the if statements seem to be running, any help would be appreciated Code: <script type = "text/javascript"> function dIM(Y, M) { with (new Date(Y, M, 1, 12)) { setDate(0); return getDate(); } } function dateDifference(birthdate1, birthdate2) { var year1 = birthdate1.getFullYear(), month1 = birthdate1.getMonth(), day1 = birthdate1.getDate(), year2 = birthdate2.getFullYear(), month2 = birthdate2.getMonth(), day2 = birthdate2.getDate(); if (day1 < day2){ month1--; day1 += dIM (year2, month2);day }; if (month1 < month2) { year1--; month1 += 12; } return [year1 - year2, month1 - month2, day1 - day2]; } function ageCalculator() { var day = document.age.inputdate.value; var month = (document.age.inputmonth.value - 1); var year = document.age.inputyear.value; var now = new Date(); thisday = now.getDate(); thismonth = now.getMonth(); thisyear = now.getFullYear(); var first = new Date(thisyear, thismonth - 1, thisday); var second = new Date(year, month - 1, day); var yourage; var datediff; if (day == "" || month == "" || year == "") { alert ("Please fill in all of the boxes before getting your age"); } else if ((day != parseInt(day)) || (month != parseInt(month)) || (year != parseInt(year))) { alert ("Please only enter digits in the day, month or year boxes"); return false; } datediff = dateDifference(first,second); if ((thismonth < month) || (thismonth == month & thisday<=day)) {thisyear--;} yourage = thisyear-year; var next = parseInt(year)+datediff[0]+1; var difference = Date.UTC(next, month, day, 0, 0, 0) - Date.UTC(thisyear, thismonth, thisday, 0, 0, 0); var daysleft = difference/1000/60/60/24; document.age.daysremaining.value = daysleft+" days left for your next birthday"; document.age.ageoutput.value = yourage; } function clear(form){ form.Result.value = ""; } </script> <center> <p> <form name = age> <p>Day of birth <input type="text" id="inputdate" size="2"><br/> Month of birth <input type="text" id="inputmonth" size="2"><br/> Year of birth <input type="text" id="inputyear" size="4" ><br/> <input name="button" type="button" id="button2" onClick="ageCalculator()" value = "Get Age"/> <input type="reset" name="Reset" id="button" value="Reset" /> </p> <p> You are <input type = "text" name = "ageoutput" size = "4" value = "0"> years old <input type = "text" name = "daysremaining" value = "0" /> </p> </form> hi, i am trying to get some javascript working on a website i am making. the javascript changes the background image behind a photo. this simulates a user selecting a different frame from the drop down list http://jimpicot.com/shop/index.php?m...&products_id=3 below is the link to another forum it have been using to get most of the website working. http://www.zen-cart.com/forum/showthread.php?t=173765 I am very new to coding, I am currently working on this design as my very first: http://img822.imageshack.us/img822/6533/unled1pd.jpg. I am currently working on the Image slider which is on the left side next to the login bar and headlines. I don't know where to start with this. If someone could walk me through or help me in anyway i would greatly appreciate it. Here is my current project LIVE: http://visionarycreativegrp.com/Demos/ForSale%20RED/# Hi I am trying to build an application which has 6 small input fields and one numeric key pad. Initially the focus should be on the first inputfield and after entering the number from the numeric key pad, it should shift the focus to third input field and the user should be able to enter the number from the numeric key pad and then shift the focus to fifth input field and user should be able to enter the number in fifth through the key pad. I have achieved till gaining the focus on the first input field and i could enter the number through the key pad and i was able to shift the focus to third input field but however whatever i enter the number is getting changed in first and third input field. the code i wrote is below Code: <html> <head> <script type="text/javascript"> function displaymessage(val) { document.getElementById('first').value = val; alert(document.getElementById('first').value); if(document.getElementById('first').value!=null) { alert("yes"); document.getElementById('third').focus(); document.getElementById('third').value = val; } } </script> </head> <body onload="document.getElementById('first').focus();"> Enter your pin: <input type="text" id="first" size="1" maxlength="1"></> <input type="text" id="second" size="1" maxlength="1" /> <input type="text" id="third" size="1" maxlength="1" /> <input type="text" id="fourth" size="1" maxlength="1" /> <input type="text" id="five" size="1" maxlength="1" /> <input type="text" name="six" size="1" maxlength="1" /> <table border="1"> <tr> <td width="30px" align="center"><input type="button" value="1" onclick="displaymessage(1)"/> </td> <td width="30px" align="center"><input type="button" value="2" onclick="displaymessage(2)"/> </td> <td width="30px" align="center"><input type="button" value="3" onclick="displaymessage(3)"/> </td> </tr> <tr> <td width="30px" align="center"><input type="button" value="4" onclick="displaymessage(4)"/> </td> <td width="30px" align="center"><input type="button" value="5" onclick="displaymessage(5)"/> </td> <td width="30px" align="center"><input type="button" value="6" onclick="displaymessage(6)"/> </td> </tr> <tr> <td width="30px" align="center"><input type="button" value="7" onclick="displaymessage(7)"/> </td> <td width="30px" align="center"><input type="button" value="8" onclick="displaymessage(8)"/> </td> <td width="30px" align="center"><input type="button" value="9" onclick="displaymessage(9)"/> </td> </tr> </tr> <tr> <td width="30px" align="center"><input type="button" value="0" onclick="displaymessage(0)"/> </td> <td width="30px" align="center"><input type="button" value="Reset"/> </td> </tr> </table> </body> </html> I know thats because I am filling the val variable again in the third input field and that is the reason it is getting changed in first and third. However I am not aware of what other best methods we could use on this. Pleasee helpp.. I have a big issue. I am doing this: I have a menu and when you click tje linsk it loads content using jquery post into a div. It alway loads javascript with it. But I find when they click another menu item it loads a different section into the div along with different javascript. But the dom is still keeping the old javascript. After about 40 clicks the site wants to stop working. How can I resolve this? Thanks Hi All, I am using a script that hides / shows a cell row depending on whether a form checkbox has been ticked. The HTML, CSS and JS code is below: CSS & HTML (simplified and normally in head / body tags etc.): Code: #lastRow { display: none;} <table> <tr> <td>Events Xtra:</td> <td><input class="text" type="Checkbox" name="upcoming" id="upcoming" value="checked"></em></td> </tr> <tr id="lastRow"> <td>Xtra Description:</td> <td><textarea name="event_description" cols="60" rows="5" id="event_description"></textarea></td> </tr> </table> JS: Code: function showHideRow(obj){ oLastRow.style.display = (obj.checked)? 'block' : 'none'; } window.onload=function(){ var oChkBox = document.getElementById('upcoming'); oLastRow = document.getElementById('lastRow'); oChkBox.onclick=function(){showHideRow(this);} showHideRow(oChkBox); } Now, the above works absolutely perfectly in Internet Explorer - when the checkbox is ticked, it displays the bottom row exactly as I want it to - i.e. as the next row in the table. However, in Chrome, Safari and Firefox it seems to display the whole row as a cell on it's own so distorting the entire table structure. I suspect it is something to do with the use of the id="lastRow", but I am not sure. The strange thing is that the HTML source is of course the same for both. Can anyone shed any light here? For convenience I have uploaded two images: IE (working fine): Firefox (distorting across page) Regards, Neil Hi guys, I'm having an issue with a my form total, I'm getting the same result no matter what positive number I enter. Every other aspect of the code seems to be working ok apart from this. eg. If I enter the number 4, the factorial number should read 24 but it's reading 1, its reading 1 no matter what number goes in there. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.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> <script type= "text/javascript"> function calcFactorial(factorialNumber) { var factorialResult = 1; for (; factorialNumber > 0; factorialNumber --){ factorialNumber = factorialResult * factorialNumber; } return factorialResult; } </script> </head> <frameset cols="100%,*"> <frame name = "fraCalcFactorial" src="calcFactorial.htm" /> <frame src="UntitledFrame-4"></frameset><noframes></noframes> </html> I believe the issue is in here somewhere but I'm not sure where. Ironically I'm learning from a book and this is from the Error handling/Debugging chapter. I'm going well on this book so far and really don't want to have to move forward without fully understanding whats going on. Any help/comments would be greatly received. Sara Hello there, I am new to UI Development, I had an issue in displaying slider, i have to use 3 sliders in my page, 2 are working fine but the 3rd slide is not getting displayed even though the code is same as the remaining 2. Below are my JS and HTML pages. Please reply me ASAP. Thank you. Java Script Code: // Time Slider $("#time_slider").slider({ range: true, min: 0, max: 1439, values: [540, 1020], slide: slideTime }); function slideTime(event, ui){ var minutes0 = parseInt($("#time_slider").slider("values", 0) % 60); var hours0 = parseInt($("#time_slider").slider("values", 0) / 60 % 24); var minutes1 = parseInt($("#time_slider").slider("values", 1) % 60); var hours1 = parseInt($("#time_slider").slider("values", 1) / 60 % 24); $("#time").text(getTime(hours0, minutes0) + ' - ' + getTime(hours1, minutes1)); } function getTime(hours, minutes) { var time = null; minutes = minutes + ""; if (hours < 12) { time = "AM"; } else { time = "PM"; } if (hours == 0) { hours = 12; } if (hours > 12) { hours = hours - 12; } if (minutes.length == 1) { minutes = "0" + minutes; } return hours + ":" + minutes + " " + time; } slideTime(); //----------------------------- // Trip Duration $("#duration_slider").slider({ value: 160, min: 0, max: 1440, step: 30, slide: slideDuration }); function slideDuration(event, ui){ var hours = Math.floor(ui.value / 60); var minutes = ui.value - (hours * 60); if(hours.length == 1) hours = '0' + hours; if(minutes.length == 1) minutes = '0' + minutes; $("#duration").text(hours+'hrs. '+minutes+'mins. '); } slideDuration(); //----------------------------- // Max Price $("#price_slider").slider({ value: 160, min: 0, max: 1440, step: 30, slide: slidePrice }); function slidePrice(event, ui){ var dollars = ui.value; $("#maxprice").text('$'+dollars); } slidePrice(); HTML Code: <head> <style> #slider-range{width:400px;} #slider-range,#time,#duration,#maxprice {margin:10px;display:block;} .ui-slider-horizontal .ui-state-default {background:url(images/scrub-btn.png) no-repeat scroll 50% 50%;} .flights-select {margin: -22px 0px 140px;} </style> </head> <body> <div class="flights-section-title">Flight Time</div> <div class="flights-section"> <ul class="inline"> <li><input class="radio" type="radio" name="2" checked="checked" value="a"><div class="flight-radio-label">Take-Off</div></li> <li><input class="radio" type="radio" name="2" value="b"><div class="flight-radio-label">Landing</div></li> </ul> <div class="leftnav-dot-divider"> <div id="time_slider"></div> <span id="time"></span></div> </div><!-- flight-section-slider --> <div class="flights-section-title">Max Trip Duration</div> <div class="flights-section"> <div class="leftnav-dot-divider"> <div id="duration_slider"></div> <span id="duration">2hrs. 0mins.</span> </div> </div><br /> <div class="flights-section-title">Max Price</div> <div class="flights-section"> <div class="leftnav-dot-divider"> <div id="price_slider"></div><span id="maxprice">$100</span> </div> </div><br /> </body Hey guys, I'm new to javascript and I'm trying to get this code to work. It's a pretty basic system to start with, just wanting to calculate the total pay for employees and using the array so that I can key multiple employees at a time. Can anyone help me adjust my code so that this system works? Thanks for your help in advance, it's greatly appreciated. Code: var NoEmps var PayRate= new Array(); var HrsWorked= new Array(); var EmpName= new Array(); var GrossPay= new Array(); var i var j NoEmps=prompt("Enter Number of Employees to process","") i = 0; while (i<NoEmps) { EmpName[i]= prompt("Enter employee name","") PayRate[i]=prompt("Enter employee pay rate","") HrsWorked[i]= prompt ("Enter hours worked","") if ((isNaN(PayRate[i]))||(isNaN(HrsWorked[i]))) { alert("Please enter numbers") flag = "false" break } if PayRate[i]>25 { alert ("Pay rate can only b $25 or less per hour") flag == "false" break } //i = i +1 } if (flag = "true") { for (j in EmpName) { GrossPay[j]=PayRate[j] * HrsWorked[j] } for (counter; counter<EmpName.length; counter++) { document.write ("Gross Pay for " + EmpName[counter] + " is $" + GrossPay[counter] + "<br>") } } Hi, I am working on simple project and it's for the institute Class project where i am learning php. i have to submit the project as soon as possible. But i am doing it different way then of i was supposed. Instead of validation message i want to use a picture or icon with Red error icon and Green yes icon as you can check in the attached picture. I am calling a function on submit button and if there is any error then using document.GetElementById('error').style.background="none" and ="pic url". I am getting output but it's just for a second then disappeared. I have already attached the Screen Shot to get the full idea.. Mainly i want to display red icon on error and green one when there is not error. I'm trying to use SmoothGallery 2.1 on my website as a featured box. I tried opening the demos provided with the code in all browsers to make sure it was compatible and it showed fine in them all. I copied the javascript onto my site and I'm able to show the gallery. However in Chrome and Internet Explorer it shows fine, but Firefox the images are spread vertically down my site and the javascript gallery box doesn't show. I don't understand why this is an issue because it shows fine opening the demo pages and the javascript code and css is a straight copy from the folder :S Can anyone help me out? Website I'm having the issue on is www.deewon.com -Thanks I'm finishing up an e-commerce website, and I can't quite figure out why the shopping cart feature is acting all screwy in Internet Explorer. It works fine in Firefox, but in IE, when you add a product to the cart it doesn't display the little pop-up notification, and when you click on the "my cart" at the top right the product quantities are incorrect about 70% of the time. For some reason IE keeps doubling the quantities; I think one of the scripts may be double refreshing the page I just can't figure out where. If anyone has any suggestions they would be much appreciated. The site I'm referring to is he www.tcatvs.com Thanks y'all! Also I'm using the jquery framework for much of the site. Can someone explain to me as to why the "New Art" button in the navigation doesn't have the "on" function as the others where you hover over the button and the text turns orange? Keep in mind, I didn't design/develop this site...I'm merely just trying to insert a button in the nav for a friend of mine. Thanks for your help it is greatly appreciated! Here's the website: http://www.thejam2.com/two/ And the code: Code: } menuImage = {}; function makeMenu(){ var imgs = ["thejam", "newart", "theartist","viewit","orderit","theCollage","theBorder","detailedImages","theMusicians"]; for(i in imgs){ menuImage[imgs[i]+"off"] = new Image(); menuImage[imgs[i]+"off"].src = "pics/menu_"+imgs[i]+".gif"; menuImage[imgs[i]+"on"] = new Image(); menuImage[imgs[i]+"on"].src = "pics/menu_"+imgs[i]+"_on.gif"; } document.write('<div id="menu"><table width="'+((ns4) ? 794 : '100%')+'" cellpadding=0 cellspacing=0 border=0>'); if(ns4) document.write('<tr><td><img src="pics/spacer.gif" width="418" height="1"></td><td><img src="pics/spacer.gif" width="94" height="1"></td><td><img src="pics/spacer.gif" width="94" height="1"></td><td><img src="pics/spacer.gif" width="94" height="1"></td><td><img src="pics/spacer.gif" width="94" height="1"></td><td><img src="pics/spacer.gif" width="94" height="1"></td></tr>'); document.write('<tr><td width="100%"> </td>'); document.write('<td width="94" background="pics/button_guitarBig.gif" width="75">' + makeButton('bios.php?artist=about','thejam','jamMenu') + '<br></td>'); document.write('<td width="94" background="pics/button_starBig.gif" width="75">' + makeButton('newart.php','newart','newart') + '<br></td>'); document.write('<td width="94" background="pics/button_guitarBig.gif" width="75">' + makeButton('bios.php?artist=mike_keirstead','theartist') + '<br></td>'); document.write('<td width="94" background="pics/button_starBig.gif" width="75">' + makeButton('jam2.php','viewit','viewMenu') + '</td>'); document.write('<td width="94" background="pics/button_guitarBig.gif" width="75">' + makeButton('jam2.php?loc=order','orderit') + '</td></tr>'); document.write('<tr><td> </td><td>'); makeJamMenu(); document.write('</td><td colspan="4" align="center">'); makeViewMenu(); document.write('</td></tr></table></div>'); } |