JavaScript - Slideshow, Looking For Display Slide Number 3 In First
Similar TutorialsHi everyone, I'm new in this forum, and hope that someone can help me out. I have created a clickable slide show and it works like it should. At the moment the pictures are changing like a .gif file. How can I do that each picture when it's changing it should slide from the left or right side? Thanks Robert I have a function below where every time a question is submitted, it will add a new row in the table with a textbox which allows numbers entry only. My question is that I don't know how to code these features in this function: 1: I want the text box to be between 0 and 100, so if text box contains a number which is above 100, it will automatically change the number to the maximum number which is 100. Does any one know how to code this in my function below in javascript: Code: function insertQuestion(form) { var row = document.createElement("tr"); var cell, input; cell = document.createElement("td"); cell.className = "weight"; input = document.createElement("input"); input.name = "weight_" + qnum; input.onkeypress = "return isNumberKey(event)"; cell.appendChild(input); row.appendChild(cell); } I am building a custom slideshow that is pulling data from an xml sheet to create each "Slide" each slide consists of several elements on the xml sheet. I have javascript currently putting together the correct information and creating a new div for each "slide". What I need is to display the first div(slide) and then hit a next button to get to display the next div(slide). Below the first set of code is a snapshot of code simply to illustrate that it is creating the correct divs. Those divs all have content in them I just took the code from firebug. 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> <body> <div id="page-wrap"> <button id="nextButton2">next('div')</button> <button id="prevButton2">prev('div')</button> <div id="start" style="background: none repeat scroll 0% 0% red;"></div> <div id="link_Babbling Brook" class="art"> <div id="link_Botany 101" class="art"> <div id="link_Cracking Up" class="art"> <div id="link_Eclipse" class="art"> <div id="link_Equinox" class="art"> <div id="link_Foliage Fluoresced" class="art"> <div id="link_In Vein" class="art"> <div id="link_Microscopic" class="art"> <div id="link_Pickup Sticks" class="art"> <div id="link_Relief" class="art"> <div id="link_Rhubarb" class="art"> <div id="link_Snow Dyed Shibori" class="art"> <div id="link_Symmetry" class="art"> <div id="link_Undulations" class="art"> <div id="link_Willow Mist" class="art"> <div id="link_Wired" class="art"> </div> </body> </html> Javascript code Code: if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } $(document).ready(function () { $.ajax({ type: "GET", url: "sites.xml", dataType: "xml", success: function (xml) { $(xml).find('art').each(function () { var id = $(this).attr('id'); var name = $(this).find('name').text(); var full = $(this).find('large').text(); var detail = $(this).find('detail').text(); var thumb = $(this).find('thumb').text(); var category = $(this).find('category').text(); var dimensions = $(this).find('dimensions').text(); var description = $(this).find('description').text(); var detailthumb = '<img src= " ' + thumb + ' " />'; var detailfull = '<iframe name= "portfolio ' + name + ' " src=" ' + detail + ' " iframe/>'; var large = '<iframe height="482px" width="786px" class="image-frame" name= "portfolio ' + name + ' " src= " ' + full + ' " />'; $('<div class="art" id="link_' + name +'"></div>').html('<div id="portfolio-content" class="' + name +'"><div class="thumb"><a href= " ' + detail + ' " target= "portfolio ' + name + ' ">' + detailthumb + '<br/></a>(Click for Detail)</div><div class="image">' + large + "</div><div class='text'><h1>" + name + "</h1>" + category + "<br/>" + dimensions + "<br/>" + description + "</div></div>").appendTo('#page-wrap'); }); var $currElement = $("#start"); $currElement.css("background", "red"); $("#nextButton2").click(function () { if(!$currElement.next('div').length){ alert("No element found!"); return false; } $currElement = $currElement.next('div'); $("div,p").css("background", ""); $currElement.css("background", "red"); }); var $currElement = $("#start"); $currElement.css("background", "red"); $("#prevButton2").click(function () { if(!$currElement.prev('div').length){ alert("No element found!"); return false; } $currElement = $currElement.prev('div'); $("div,p").css("background", ""); $currElement.css("background", "red"); }); } }); }); Im currently running out of ideas of how else to attack this. This page will be navigated to by clicking on a thumbnail that will then open that particular element. How do I also get it to open to the correct element in the xml sheet. PLEASE HELP I'm not sure whether this is a javascript or CSS related problem so sorry if I've posted this in the wrong place. I'm modifying a slideshow plugin to fit my website and have changed some of the dimensions of the slides. Now the next slide is coming in from the wrong position on the right hand side. I'm not sure how to fix this, can someone please help? http://ah.mjtippet.com/ I am learning Javascript and HTML5... I am trying to create a slideshow using canvas with text display of what the current image is. I have done this without canvas but I want to use canvas this time. My idea involves using the file name as the text display. Here is my working slideshow.. Code: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Slide Show</title> <script type="text/javascript"> function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } </script> <script type="text/javascript"> var imagePaths = [ "images/Summer.jpg", "images/Spring.jpg", "images/Fall.jpg", "images/Winter.jpg", "images/Puppies.jpg", "images/Duck.jpg" ]; var showCanvas = null; var showCanvasCtx = null; var img = document.createElement("img"); var currentImage = 0; window.onload = function () { showCanvas = document.getElementById('showCanvas'); showCanvasCtx = showCanvas.getContext('2d'); img.setAttribute('width','480'); img.setAttribute('height','360'); } function nextImage() { currentImage++; if (currentImage >= imagePaths.length) currentImage = 0; img.setAttribute('src',imagePaths[currentImage]); img.onload = function() { showCanvasCtx.drawImage(img,0,0,480,360); } } function prevImage() { currentImage--; if (currentImage < 0) currentImage = imagePaths.length-1; img.setAttribute('src',imagePaths[currentImage]); img.onload = function() { showCanvasCtx.drawImage(img,0,0,480,360); } } </script> <style type="text/css"> <!-- #showCanvas { background-image: url(images/Summer.jpg); } #center { height: 360px; width: 491px; float: right; } #slideArea { height: 381px; width: 600px; margin-right: auto; margin-left: auto; } #right { height: 361px; width: 52px; float: right; } #left { float: left; height: 360px; width: 52px; } #nxtBtn { width: 57px; height: 57px; position: relative; top: 120px; } #bkBtn { height: 57px; width: 57px; position: relative; top: 120px; } #displayText { width: 600px; height: 20px; float: left; text-align: center; } --> </style> </head> <body> <br /> <div id="slideArea"> <div id="right"> <a href="#" id="nxtBtn"onClick="nextImage()"onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Next','','images/arrow-right-B.png',1)"><img src="images/arrow-right-A.png" name="Next" width="51" height="75" border="0"></a> </div> <div id="left"> <a href="#" id="bkBtn" onClick="prevImage()"onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Left','','images/arrow-left-B.png',1)"><img src="images/arrow-left-A.png" name="Left" width="51" height="75" border="0"></a></div> <div id="center"> <center> <canvas id="showCanvas" width="480" height="360" > Your browser does not support the canvas tag. <br /> Please upgrade your browser </canvas> </center> </div> <div id="displayText">Display Text</div> </div> </body> </html> This is what I came up with so far but it doesn't work. Code: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Slide Show</title> <script type="text/javascript"> function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } </script> <script type="text/javascript"> ////added this code to be able to pull the display text from "imageName" var imagePath = ["images/]; var imageName = [ "Summer", "Spring", "Fall", "Winter", "Puppies", "Duck" ]; var imagePaths = imagePath + imageName + ".jpg"; ///////////////////// var showCanvas = null; var showCanvasCtx = null; var img = document.createElement("img"); var currentImage = 0; window.onload = function () { showCanvas = document.getElementById('showCanvas'); showCanvasCtx = showCanvas.getContext('2d'); img.setAttribute('width','480'); img.setAttribute('height','360'); } function nextImage() { currentImage++; if (currentImage >= imagePaths.length) currentImage = 0; img.setAttribute('src',imagePaths[currentImage]); img.onload = function() { showCanvasCtx.drawImage(img,0,0,480,360); } } function prevImage() { currentImage--; if (currentImage < 0) currentImage = imagePaths.length-1; img.setAttribute('src',imagePaths[currentImage]); img.onload = function() { showCanvasCtx.drawImage(img,0,0,480,360); } } </script> <style type="text/css"> <!-- #showCanvas { background-image: url(images/Summer.jpg); } #center { height: 360px; width: 491px; float: right; } #slideArea { height: 381px; width: 600px; margin-right: auto; margin-left: auto; } #right { height: 361px; width: 52px; float: right; } #left { float: left; height: 360px; width: 52px; } #nxtBtn { width: 57px; height: 57px; position: relative; top: 120px; } #bkBtn { height: 57px; width: 57px; position: relative; top: 120px; } #displayText { width: 600px; height: 20px; float: left; text-align: center; } --> </style> </head> <body> <br /> <div id="slideArea"> <div id="right"> <a href="#" id="nxtBtn"onClick="nextImage()"onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Next','','images/arrow-right-B.png',1)"><img src="images/arrow-right-A.png" name="Next" width="51" height="75" border="0"></a> </div> <div id="left"> <a href="#" id="bkBtn" onClick="prevImage()"onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Left','','images/arrow-left-B.png',1)"><img src="images/arrow-left-A.png" name="Left" width="51" height="75" border="0"></a></div> <div id="center"> <center> <canvas id="showCanvas" width="480" height="360" > Your browser does not support the canvas tag. <br /> Please upgrade your browser </canvas> </center> </div> <div id="displayText">Display Text</div> </div> </body> </htm> Any help would be greatly appreciated. Just wondering what the code is for a phone number to be displayed nn-nnnnnnnn for example: 67 43289482 current code is Code: var pn = document.contact_form.phonenum.value; if ((pn.length != 10) || (/[^0-9]/g.test(pn))) { // 10-digit phone number alert ( "Please fill in your 10-digit telephone number" ); return false; } So I've got my code ready to generate a random number between a certain range and printing it out in text. What I'm trying to accomplish with this code is to print the actual image as well as the text. I'm aware that there is an error in my document.write line, and that it's not the best solution. I was hoping for some suggestions to change/improve this last bit. Thanks in advance! Code: <html> <title>RANDOM IMAGE TO NUMBER RANGE</title> <body> <center> <script language="javascript" type="text/javascript"> var ranges = [ { from: 11, image: "image4.jpg" }, { from: 1, image: "image3.jpg" }, { from: -9, image: "image2.jpg" }, { from: -20, image: "image1.jpg" } ]; var random_num = (Math.round((Math.random()*41)+-20)); var image = "default"; for(var i = 0; i < ranges.length; ++i) { if(random_num >= ranges[i].from) { image = ranges[i].image; break; } } { document.write("Text: " + random_num + " Text, " + " Image: = " + image); { document.write('<img src="images/' + ranges[i].image); } } </script> <br></br> <div> CLICK <a href="javascript:history.go(0);">REFRESH or F5</a> FOR A RANDOM IMAGE on NUMBER-RANGE. </div> </center> </body> </html> So never done this one before so I am having a bit of a time trying to figure this one out. Say I have a list of LI element and only a few of them have a inline style of display block, the rest have a display of none. How would I go about looping through and dertmining the number of elements that have a display of block? Code: for(var m = 0; m < li.style.display.length; i++) { alert(m); }; The above is just crazy but where my mind melts.. Hi, I'm a complete novice using javascript. I'm trying to get a mootools plugin to work with a slide in/slide out javascript using multiple divs. Here's the page: http://pawsdogs.com/test/Site/work2.htm The mootools code (Noobslide) slides a main image on the right when you click thumbnails on the left, which are wrapped in a thumb mask using CSS. The first row of thumbnails works perfectly, but when it's passed on to the next div the mask isn't passed on and the effect breaks down. Thanks so much if anyone can help! Here's the html: Code: <li><a href="#" id="slidecontrol_2" class="slidecontrol">Click Here</a> <div id="slidedisplay_2" style="display:none;"> <div id="thumbs7"> <div class="thumbs"> <div><img src="images2/img4.jpg" alt="Photo Thumb" /></div> <div><img src="images2/img5.jpg" alt="Photo Thumb" /></div> <div><img src="images2/img6.jpg" alt="Photo Thumb" /></div> </div> <div id="thumbs_mask7"></div> <p id="thumbs_handles7"> <span></span> <span></span> <span></span> </p> </div> </div></li> <li><a href="#" id="slidecontrol_3" class="slidecontrol">asdf</a> <div id="slidedisplay_3" style="display:none;"> <div id="thumbs7"> <div class="thumbs"> <div><img src="images2/img2.jpg" alt="Photo Thumb" /></div> <div><img src="images2/img3.jpg" alt="Photo Thumb" /></div> </div> <div id="thumbs_mask7"></div> <p id="thumbs_handles7"> <span></span> <span></span> </p> </div> </div> The javascript: Code: $(document).ready(function () { $('a.slidecontrol').click(function(){ var $this = $(this); var divID = $this.attr("id").replace("slidecontrol_", "slidedisplay_"); var $div = $('#'+divID); if ($div.is(':visible')) { $div.slideUp(500); } else { $div.slideDown(500); } return false; }); }); The CSS: Code: #thumbs7{ position:relative; width:200px; clear:both; height:41px; overflow:hidden; } #thumbs7 .thumbs, #thumbs_handles7, #thumbs_mask7{ position:absolute; top:0; width:100%; height:41px; } #thumbs7 .thumbs div, #thumbs_handles7 span{ display:block; width:60px; height:41px; margin:0; float:left; cursor:pointer; } #thumbs7 .thumbs div img{ width:54px; float:right; } #thumbs_handles7 span{ background:url(../images2/thumb_invisible.gif) no-repeat; } #thumbs_mask7{ width:1200px; background:url(../images2/thumbs_mask.gif) no-repeat center top; } When I used toFixed() method on a number, I thought that this method round a number to a specified approximation, but I got a surprising result, the number became string! 15.23689 .toFixed ( 2 ) ==> "15.24" So does it convert the number into string? I am trying to figure out how to make a random number I can plug into a script count down from that number at certain times of the day until it reaches 0. I would like it to reset itself at midnight every day. I'm trying to make it work with a script I found on here that resets itself at midnight every day. So instead of it counting down too fast, it would count down to the next number after a randomly generated number of minutes until it reaches 0. But it wouldn't necessarily have to end at 0 at midnight. It could go from 845 to 323 at the end of the day at a slower pace. Is that possible?
I need a sort of slide show feature for my page (specifics below). I've spent a lot of time researching this and have not found what I'm looking for. I'm new to jquery and not sure how big of a chore this will be, but here goes: 1. There will be a title bar placed within a right and left arrow on either side. 2. The right and left arrows should cycle through a list of titles (when the right/left arrow is clicked, the title bar will change to the next/previous title in the list). 3. When each title bar is moused over, a new image will fade in above, and then fade out on mouse out. I hope this all makes sense. I'm not looking for some fancy predesigned slideshow, I'll be using my own layout and images. I just need the basic code to perform these actions. Any help would be most appreciated.. i am trying to slide multiple elements in my page at the same time. I wrote a script that can do one element at a time: Code: var count; var obj; function slide(elem,endy,endx,time){ obj=elem; count=time; currenty=obj.style.top.split('p')[0]; currentx=obj.style.left.split('p')[0]; deltay=endy-currenty; deltax=endx-currentx; yrate=deltay/time; xrate=deltax/time; framey=0; framex=0; fooy=setInterval("movey(obj)",1); foox=setInterval("movex(obj)",1); } function movex(obj){ framex++; currentx=currentx*1+xrate; obj.style.left=Math.floor(currentx); if(framex==count){ clearInterval(foox); } } function movey(obj){ framey++; currenty=currenty*1+yrate; obj.style.top=Math.floor(currenty); if(framey==count){ clearInterval(fooy); } } is their anyway to modify this code so it does not use global variables and can run multiple instances simulatnuasly. Hello guys! :-) So, this is my first post so bare with me I'm currently under education as a webdesigner/developer, and for my exams i need this slide-in function, of a <div> i made. It has to be javascript, and as simple as possible :-) I've found alot of working scripts, but with all sorts of useless junk I can't have in my final result. So: Does any of you know a simple method of making an object slide-in from the side on MO, and slide back out when mouse is removed? Ty in advance! :-) I have the following 3 buttons on my page. I need when on hover on each respective button, the button to light up with a bg image and a slide out rollover in the top direction. How can I achieve this? <div style="padding-left:45px;width:852px;"> <a href=".html" class="Button"> <div style="text-align:center;padding-top:15px;float:left;width:270px;height:45px;background-image:url(images/homeBG.png);background-repeat:no-repeat"> <span id="homeButtonText">Question 1</span><br /> </div> </a> <a href="" class="Button"> <div style="margin-left:18px;text-align:center;padding-top:15px;float:left;width:270px;height:45px;background-image:url(images/homeBG.png);background-repeat:no-repeat"> <span id="homeButtonText">Question 2</span><br /> </div> </a> <a href="" class="Button"> <div style="text-align:center;padding-top:15px;float:right;width:270px;height:45px;background-image:url(images/homeBG.png);margin-right:5px;background-repeat:no-repeat"> <span id="homeButtonText">Question 3</span><br /> </div> </a> </div> Good Day: I am very interested in a slide show as seen on this website (www.linksyssolutions.com). Can anyone direct me as to where I could find a script for this slideshow to use on my site. Thanks very much in advance. I am using ASP.NET and AJAX here. basically what I want is a nice little slide effect to show the next batch of images in a mini slide show. Example: << prev [image1] [image2] [image3] [image4] Next >> << prev [image5] [image6] [image7] [image8] Next >> so when the user presses next or previous, it will SLIDE to the left/right. the databinding is done at the server side end and in an update panel so it does an async postback when they press next/prev. how can I go about doing this type of effect? I'm trying to create a menu navigation system from the top of the page. I want it so when I hover over the link, it drops down (the link drops down; so it'd be as if there was a whole field being hidden beyond the 0px mark) with the related field. I've gotten it to work, somehow but it still isn't right. A few issues a - when I hover over .drop_slide and then if I choose to close it by hovering back over the .drop_slide it does as it's told, which is "slide, slide". I'm interested in rectifying this issue so it doesn't do that, however I just don't know how. - The idea is to have multiple links in the .slide, so I need it to be constantly open while the user mouses over the other links. Should this be created in one field? If so, how would I do that with a drop down in mind? - Am I approaching this completely wrong? Lol. Should I be researching into .animate? I've been looking at it actually, but I can't get anything to grow negatively. Say; marginTop: -85px or something. ANY help is appreciated, thanks! Code: <html> <head> <title>test slide panel</title> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ function slide() { $("#panel").slideToggle("slow"); } $(".drop_slide").hover(slide, stop); $("#panel").hover(stop, slide); }); </script> <style type="text/css"> body { margin: 0 auto; padding: 0; width: 570px; font: 75%/120% Arial, Helvetica, sans-serif; } a:focus { outline: none; } #panel { background: grey; height: 200px; display: none; } .slide { margin: 0; padding: 0; background-color: red; } .drop_games { width: 200px; height: 31px; padding: 10px 10px 0 0; display: block; font: bold 120%/100% Arial, Helvetica, sans-serif; color: #fff; text-decoration: none; } </style> </head> <body> <div id="panel"> additional links here...or information </div> <p class="slide"><a href="#" class="drop_slide">test link</a></p> </body> </html> |