JavaScript - Enlarging Thumbnails Stored In Array
So when the page loads the thumbnails cycle through using setInterval. When the user clicks on one of the thumbnails, it is supposed to open a new window and show the enlarged version of that thumbnail stored in bigpics. However it only comes up with a broken image link. Any ideas why this is not working? Here is the code:
<html> <head> <title>Untitled</title> </head> <script language="JavaScript" type="text/javascript"> <!-- var pics = new Array() pics[0]="pict1.gif" pics[1]="pict2.gif" pics[2]="pict3.gif" pics[3]="pict4.gif" pics[4]="pict5.gif" pics[5]="pict6.gif" var bigpics = new Array() bigpics[0]="pict12.gif" bigpics[1]="pict22.gif" bigpics[2]="pict32.gif" bigpics[3]="pict42.gif" bigpics[4]="pict52.gif" bigpics[5]="pict62.gif" i=0 setInterval("slide()",500) function slide(){ if (i<pics.length) i++ if (i==pics.length) i=0 document.images[0].src=pics[i] } function enlarge(x){ w=window.open() x=bigpics[i] w.document.write("<img src='x'>") } //--> </script> <body> <img src="pict1.gif" alt="" onclick="enlarge(this)"> </body> </html> Similar TutorialsHi, I have a php script that gets all images in my directory and outputs them as gallery[0]=firstimage.jpg, [1], [2], ... The php script is supposed to work with the javascript, so to cover all angles here is the php Code: <? //PHP SCRIPT: getimages.php Header("content-type: application/x-javascript"); //This function gets the file names of all images in the current directory //and ouputs them as a JavaScript array function returnimages($dirname=".") { $pattern="(\.jpg$)|(\.jpeg$"); //valid image extensions $files = array(); $curimage=0; if($handle = opendir($dirname)) { while(false !== ($file = readdir($handle))){ if(eregi($pattern, $file)){ //if this file is a valid image //Output it as a JavaScript array element echo 'gallery['.$curimage.']="'.$file .'";'; $curimage++; } } closedir($handle); } return($files); } echo 'var gallery=new Array();'; //Define array in JavaScript returnimages() //Output the array elements containing the image file names ?> Then this javascript uses the array for a slideshow, only I want to list each image as a small thumbnail. This will allow me to view the images on my webserver much more eye friendly. Code: <script type="text/javascript"> var curimg=0 function rotateimages(){ document.getElementById("slideshow").setAttribute("src", "images/"+gallery[curimg]) curimg=(curimg<gallery.length-1)? curimg+1 : 0 } window.onload=function(){ setInterval("rotateimages()", 2500) } </script> <div style="width: 170px; height: 160px"> <img id="slideshow" src="images/bear.gif" /> </div> I'm not sure how to go about listing all the images. I was thinking about using definition lists and only selecting the last 10 images. I can insert images into the definition description so I thought that was my best shot. I get stuck on choosing the images from the array, I attempt something like the following Code: <img src="gallery[gallery.length-11]" /> </dd> But that looks for a file, not the array. I then modified the script to get me the most recent images (if I were to add/remove images). Does this look correct? Code: <script type="text/javascript"> var curimg=0 function newestimg(){ document.getElementById("largethumb").setAttribute("src", "images/"+gallery[curimg]) curimg=(curimg<gallery.length-1)? gallery.length-1 : curimg } </script> I am looking to have the user input a word into a textbox then when the user hits an "Add" button, the word is stored to an array and then is displayed in a table. I also want the textbox to clear after the "Add" button is pressed. Next, I want the user to be able to input another word into the textbox and when the "Add" button is pressed, have that word stored to same array as the first word but just to a different number. e.g. ingredient(0)=first word; ingredient(1)=second word. Then I want the second word to be displayed right below the first word in the table, in the next line down.This is what I have so far. You can also see at http://www.stuffedpantry.com/startsearch.html <code> <html> <head> <title>Stuffed Pantry~Recipe Search (Under Construction)</title> <link rel="stylesheet" type="text/css" href="main.css"> </head> <body> <script type="text/javascript"> var ingredients=new Array(); </script> <div id="lftBar"> </div> <div id="level0"> <div id="level1"> <div id="level3"> <div id="rgtBar"> <script type="text/javascript"><!-- google_ad_client = "pub-1493036398028662"; /* 160x600, created 3/15/10 */ google_ad_slot = "0764917859"; google_ad_width = 160; google_ad_height = 600; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </div> <div id="topBar"> <img class="displayed" src="logo.jpg"> <div id="advBar"> <p align="center"><font font size="6" color="darkblue"><b><i>A recipe search engine.</i></b></font></p> </div> </div> <div id="level2"> <div id="main"> <p align="center"><font font size="4">Welcome to the search engine of stuffedpantry.com! This page is designed to to help you search our database of recipes to find the perfect recipe for you! So to begin, type in an ingredient. Any ingredient will work! You could put in a type of seasoning, like paprika. Or you can put in a type of soup, like chicken noodle soup! Anything that is considered food will work! And if there isn't a recipe containing the ingredient(s) you have chosen, then submit one to us! You can submit one <a href="recipesubmit.html">here!</font></a> <div id="level4"> <form > <table border="0" cellpadding="0" cellspacing="0" align="center"> <tr><td align="center"><label for="ingredient"><b>Enter Ingredient: </b></label><input type="text" name="ingredient" id="textbox1" style="width:200px;"><div style="clear:left;height:20px;"></div></td><td> <tr><td align="center"><input type="button" value=" Add " onclick="getElementById('ing').innerHTML = getElementById('textbox1').value"></td></tr> <tr><td> </td></tr> <tr><td id="ing"</td></tr> <tr><td> </td></tr> <tr><td align="center"><input type="radio" name="choose" value="only" checked>Search recipes that have <b>ONLY</b> these ingredients<br/><input type="radio" name="choose" value="including">Search recipes that <b>INCLUDE</b> these ingredients</td></tr> <tr><td> </td></tr> <tr><td align="center"><input id="button1" type="submit" value=" Search! "</td></tr> </form> </div> </div> </div> </div> </div> </div> </body> </html> </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>Slayeroffice Image Slider (altered)</title> <script> var img = new Array(); img[0] = "http://www.blogsdna.com/wp-content/uploads/2011/03/Google-labs.png"; img[1] = "http://thenextweb.com/socialmedia/files/2010/07/youtube_logo.png"; img[2] = "http://www.techlifeweb.com/facebook_logo.jpg"; img[3] = "http://hackingarticles.com/wp-content/uploads/gmail_logo_stylized.png"; for(var image=[], p=0; p<img.length; p++){ image[p] = new Image(); image[p].src = img[p]; } var current = 0; window.onload = function so_init() { if(!document.getElementById || !document.createElement){ return; } for(var q=0; q<img.length; q++){ imgs = document.createElement("img"); imgs.src = img[q]; img[q].style.display = "none"; document.getElementById("imageContainer").appendChild(imgs.cloneNode(true)); } for(i=1;i<img.length;i++){ img[i].xOpacity = 0; } img[0].style.display = "block"; img[0].xOpacity = .99; setTimeout(so_xfade,1000); } function so_xfade() { cOpacity = imgs[current].xOpacity; nIndex = imgs[current+1] ? current+1 : 0; nOpacity = imgs[nIndex].xOpacity; cOpacity-=.05; nOpacity+=.05; img[current].xOpacity = cOpacity; img[nIndex].xOpacity = nOpacity; img[nIndex].style.display = "block"; setOpacity(img[current]); setOpacity(img[nIndex]); if(cOpacity<=0) { img[current].style.display = "none"; current = nIndex; setTimeout(so_xfade,1000); } else { setTimeout(so_xfade,100); } } function setOpacity(obj) { if(obj.xOpacity>.99) { obj.xOpacity = .99; return; } obj.style.opacity = obj.xOpacity; obj.style.MozOpacity = obj.xOpacity; obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")"; } </script> <style> #imageContainer { height:309px; } #imageContainer img { width:500px; height:309px; position:absolute; top:0; left:0; } </style> </head> <body> <div id="imageContainer"> <!-- <img src="http://www.blogsdna.com/wp-content/uploads/2011/03/Google-labs.png" alt="Swimming Pool Water" /> <img src="http://thenextweb.com/socialmedia/files/2010/07/youtube_logo.png" alt="Notebook" /> <img src="http://www.techlifeweb.com/facebook_logo.jpg" alt="Bottle Neck" /> <img src="http://hackingarticles.com/wp-content/uploads/gmail_logo_stylized.png" alt="Nail in a Board" /> --> </div> </body> </html> The script works if the images are stored within the HTML but when I try to store them in the JS array, it fails. Is there any way to store the images in JS with this script? Can you tell me a similar way to do this? Please see URL: http://backstageweb.net/2011/web.htm At the bottom of the page, I want to create nav links on these thumbnail images (NOT the large main images above them) so that each portfolio piece can go to its own page that has its own descriptive text in the left sidebar. There is no HTML for the thumbnails; they are generated via .js. Can this be done? .js file attached. Better yet, if it's not too difficult, I would love to switch out the text with some cool .js code so all the functionality could be contained within this single page, instead of linking to individual HTML pages (like when you click another thumbnail, the text slides up and out of sight, and the new text slides up from the bottom to replace the former text) but I fear this may be over my head. I'll settle for the more primitive approach. Also, on a more minor issue, for some reason a thumbnail for the last list item does not display. You'll see my page displays 3, but the code contains 4: Code: <div id="maingallery"> <div id="slides"> <ul> <li><img width="700" height="525" alt="" src="images/WebLgTerraVoce.jpg"></li> <li><img width="700" height="525" alt="" src="images/WebLgSpca2.jpg"></li> <li><img width="700" height="525" alt="" src="images/WebLgSalon.jpg"></li> <li><img width="700" height="525" alt="" src="images/WebLgTerraVoce.jpg"></li> </ul> </div> </div> (I'm not too worried about this second issue, but I'd be happy to fix it if you can tell me how) Thanks for any help. John I have a request for a lightbox that has the image which expands to fit the height or width, and also displays the thumbnails of the previous and next image. They want it to behave similar to this: http://www.karamann.com/#/interiors/...lakeshore/zoom Can someone point me to either a tutorial or an existing script? I've found dozens of lightboxes, but none with the thumbnails. I do have a lightbox that has static prev/next buttons. Is there any way I can have the script replace those buttons with thumbnails? Would this be the way to go? Ive searched everywhere for an image gallery script which shows only thumbnails. -Ive found none =/ What i want is something like this: http://www.dhtmlgoodies.com/scripts/...ideshow-5.html BUT i do want just the small thumbnails thats slideable. The below gallery-link is what I want, but it should be sliding like the thumbnails in the above gallery so that I don't have to place 100 pictures in one page. http://www.gethifi.com/demos/jphotogrid Ive found galleries in flash, but it would be great to not have to use flash.. an1 knows about a script like the one in my description? Im not awsome at scripts. I know a little, and have tried to modify some scripts, but ive given up I'm using the Nivo slider (http://nivo.dev7studios.com/) for a banner with different thumbnails for the controls. After several hours of wrestling with the CSS, I was able to make it so each thumbnail could have its own style and hover. Now the JS doesn't work - meaning, the banner doesn't slide when I click any of the thumbnails. Can anyone help me out with this? I'm very much a beginner with JS. Here's my HTML: Code: <div id="slider" class="nivoSlider"> <img src="images/banner-1.jpg" alt="" /> <img src="images/banner-2.jpg" alt="" /> <img src="images/banner-3.jpg" alt="" /> <img src="images/banner-2.jpg" alt="" /> <span class="nivo-controlNav"> <a class="nivo-control smerch"> </a> <a class="nivo-control gervais"> </a> <a class="nivo-control karl"> </a> <a class="nivo-control insects"> </a> </span> </div> Here's my CSS: Code: /*============================*/ /*=== Custom Slider Styles ===*/ /*============================*/ #slider { position:relative; width:984px; height:501px; background:url(images/loading.gif) no-repeat 50% 50%;} #slider img { position:absolute; top:0px; left:0px; display:none;} #slider a { border:0; display:block;} .nivo-controlNav { position:absolute; left:260px; bottom:-42px;} .nivo-controlNav a { display:block; width:99px; height:67px; border:0; margin-right:3px; float:left;} .nivo-controlNav a.active { background-position:0 -22px;} .nivo-directionNav a { display:block; width:30px; height:30px; background:url(images/arrows.png) no-repeat; text-indent:-9999px; border:0;} a.nivo-nextNav { background-position:-30px 0; right:15px;} a.nivo-prevNav { left:15px;} .nivo-caption { text-shadow:none; font-family: Helvetica, Arial, sans-serif;} .nivo-caption a { color:#efe9d1; text-decoration:underline;} /*====================*/ /*=== Other Styles ===*/ /*====================*/ .clear {clear:both;} #slider .nivo-controlNav { position:absolute; bottom:0; /* Put the nav below the slider */ left: 0; width: 984px;} #slider .nivo-controlNav img { display:inline; /* Unhide the thumbnails */ height: 67px; width: 99px; position: relative;} .nivo-control { cursor:pointer;} .nivo-controlNav a {position: absolute; bottom: -122px;} .smerch {right: 38px; background: url(images/mn-thumb-1.png) top left no-repeat;} .smerch:hover{background: url(images/mn-thumb-1-over.png) top left no-repeat;} .gervais {right: 134px; background: url(images/mn-thumb-2.png) top left no-repeat;} .gervais:hover{background: url(images/mn-thumb-2-over.png) top left no-repeat;} .karl {right: 238px; background: url(images/mn-thumb-3.png) top left no-repeat;} .karl:hover{background: url(images/mn-thumb-3-over.png) top left no-repeat;} .insects {right: 342px; background: url(images/mn-thumb-4.png) top left no-repeat;} .insects:hover{background: url(images/mn-thumb-4-over.png) top left no-repeat;} Not sure if this is needed, but here's the section of the JS for the controls: Code: //Add Control nav if(settings.controlNav){ var nivoControl = $('<div class="nivo-controlNav"></div>'); slider.append(nivoControl); for(var i = 0; i < kids.length; i++){ if(settings.controlNavThumbs){ var child = kids.eq(i); if(!child.is('img')){ child = child.find('img:first'); } if (settings.controlNavThumbsFromRel) { nivoControl.append('<a class="nivo-control" rel="'+ i +'"><img src="'+ child.attr('rel') + '" alt="" /></a>'); } else { nivoControl.append('<a class="nivo-control" rel="'+ i +'"><img src="'+ child.attr('src').replace(settings.controlNavThumbsSearch, settings.controlNavThumbsReplace) +'" alt="" /></a>'); } } else { nivoControl.append('<a class="nivo-control" rel="'+ i +'">'+ (i + 1) +'</a>'); } } I'm at a loss. Any help would be great. Thanks. Here's a quick visual of the parts of the slider: http://i.imgur.com/tkE2Y.png Hello, I would like to take current page (which has virtualpaginate numbers below the images to advance through them) and instead of having numbers, to have thumbnails which will be across the bottom of the page (in the footer div)... I will have about 35-40 thumbnails and I'd like it so that the thumbnails correspond to the image that is displayed. I also would like to have the thumbnails be a "slider" type of script which allows the user to browse through the thumbnails by moving their mouse left-and-right The image in the center DIV (and its accompanying information) should be replaced OnClick, not on hover over the thumbnails. I haven't been able to find an example of this, but I was wondering if someone could point me in the correct direction to achieve this. Here is my current 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>Viviana Santamarina</title> <style type="text/css"> html, body { background-color: #111; width: 1100px; margin-right: auto; margin-left: auto; margin-top: 50px; padding: 0px; border: 0px; } p { color: white; font-family: arial; font-size: 18px; font-weight: bold;} h1 { color: white; font-family: arial; font-size: 24px; font-weight: bold;} h5 { color: white; font-family: arial; font-size: 16px;} h6 { color: white; font-family: arial; font-size: 12px; margin-top: 0px;} a { color: white; font-family: arial; font-size: 14px; font-weight: bold;} #container { width: 1000px; margin: 0 0 0 20px; /* top right bottom left */ padding: 0; background-color: #111; } #container #col1 { background: #000; height: 600px; width: 250px; float: left; } #container #col2outer { width: 750px; float: right; margin: 0; padding: 0; } #col2outer #col2mid { background: #000; height: 600px; width: 500px; float: left; } #col2outer #col2side { background: #000; height: 600px; width: 250px; float: right; } #col2outer #portfolio { background: #000; height: 450px; width: auto; float: center; } #col2outer #pages { background: #000; height: 50px; width: 250px; float: bottom; margin: 20px; } #container #footer { float: left; width: 870px; } </style> <link rel="stylesheet" type="text/css" href="css/tabs-accordion.css"/> <link rel="stylesheet" type="text/css" href="css/jquery.lightbox-0.5.css" media="screen" /> <script type="text/javascript" src="js/jquery.js"></script> <script src="js/jquery.tools.min.js"></script> <script type="text/javascript" src="js/virtualpaginate.js"></script> <script type="text/javascript" src="js/jquery.lightbox-0.5.js"></script> <!-- is the accordian another script file that's missing from this list? --> <!-- do the lightbox and accordian scripts need to be loaded in a certain order? --> <script type="text/javascript"> $(function() { $('#gallery a').lightBox(); // Select all links in object with gallery ID $("#accordion").tabs("#accordion div.pane", {tabs: 'h2', effect: 'slide', initialIndex: null}); }); </script> </head> <body> <div id="container"> <h1>Viviana Santamarina - Paper Knitted Sculptures</h1> <div id="col1" align="center"> <div id="accordion"> <h2><strong>ABOUT MY WORK </strong></h2> <div class="pane" style="display:block" align="left"> <h6 align="left"> Turning humble tools like pencils into hooks and paper into strips allows me to leave graphite traces while the paper is being knitted, a deconstructed drawing of sorts.<br><br> While the stitches grow, interdependence grows as well. The tension that both elements generate a structural and narrative balance by circling what it is and giving edge to the void. <br><br> <a href="readmore.html">read more</a> </h6> </div> <h2><strong>RECENT AWARDS</strong></h2> <div class="pane" align="left"> <h6 align="left"> Turning humble tools like pencils into hooks and paper into strips allows me to leave graphite traces while the paper is being knitted, a deconstructed drawing of sorts.<br><br> While the stitches grow, interdependence grows as well. The tension that both elements generate a structural and narrative balance by circling what it is and giving edge to the void. <br><br> <a href="readmore.html">read more</a> </h6> </div> <h2><strong>PREVIOUS EXHIBITIONS</strong></h2> <div class="pane" align="center"> <p> Gertrude Herbert "A Sense of Place 2010" Augusta, GA September 17th - November 5th, 2010 http://www.ghia.org/ </p> </div> <h2><strong>CONTACT INFORMATION</strong></h2> <div class="pane" align="center"> <h6 align="left"> Turning humble tools like pencils into hooks and paper into strips allows me to leave graphite traces while the paper is being knitted, a deconstructed drawing of sorts.<br><br> While the stitches grow, interdependence grows as well. The tension that both elements generate a structural and narrative balance by circling what it is and giving edge to the void. <br><br> <a href="readmore.html">read more</a> </h6> </div> </div> </div> <div id="col2outer"> <div id="col2mid" align="center"> <p>PORTFOLIO</p> <div id="portfolio"> <div class="virtualpage hidepiece"> <div id="gallery"> <a href="images/work/highres/EVA.jpg" title="Sitting Nude, 2010"><img src="images/work/EVA.jpg" class="img" border="0" /></a> <h5>"Sitting Nude" 2010 <p></h5> <h6>Medium: paper crochet<br> Dimensions: 24" x 22" x 32"<br> </h6> </div> </div> <div class="virtualpage hidepiece"> <div id="gallery"> <a href="images/work/highres/Corset.jpg" title="Corset, 2009"><img src="images/work/Corset.jpg" class="img" border="0"/></a> <h5>"Corset" 2009 <p></h5> <h6>Medium: paper crochet<br> Dimensions: 30" x 20" x 3"<br> </h6> </div> </div> <div class="virtualpage hidepiece"> <div id="gallery"> <a href="images/work/highres/Browsing2.jpg" title="Browsing 2, 2010"> <img src="images/work/Browsing2.jpg" class="img" border="0"/></a> <h5>"Browsing 2" 2010 <p></h5> <h6>Medium: paper crochet, book<br> Dimensions: 8" x 11" x 10"<br> </h6> </div> </div> <div class="virtualpage hidepiece"> <div id="gallery"> <a href="images/work/highres/ShapingTheVoid.jpg" title="Shaping The Void, 2010"><img src="images/work/ShapingTheVoid.jpg" class="img" border="0"/></a> <h5>"Shaping The Void" 2009 <p></h5> <h6>Medium: paper crochet, pencils<br> Dimensions: 22" x 14" x 14"<br> </h6> </div> </div> <div class="virtualpage hidepiece"> <a href="images/work/TandemRowingl.jpg" rel="lightbox"><img src="images/work/TandemRowing.jpg"></a> </div> </div> <!-- Pagination DIV --> <div id="pages"> <div id="gallerypaginate" class="paginationstyle"> <a href="#" rel="previous"><<</a>   <span class="flatview"></span>  <a href="#" rel="next" class="imglinks">>></a> </div> </div> <!-- Initialize --> <script type="text/javascript"> var gallery=new virtualpaginate({ piececlass: "virtualpage", //class of container for each piece of content piececontainer: 'div', //container element type (ie: "div", "p" etc) pieces_per_page: 1, //Pieces of content to show per page (1=1 piece, 2=2 pieces etc) defaultpage: 0, //Default page selected (0=1st page, 1=2nd page etc). Persistence if enabled overrides this setting. persist: false //Remember last viewed page and recall it when user returns within a browser session? }) gallery.buildpagination(["gallerypaginate", "gallerypaginate2"]) </script> </div> <div id="col2side" align="center"> <p>UPCOMING SHOWS</p> <h6 align="left"> Cherry Creek Art Festival<br> Denver, CO<br> July 2nd - 4th, 2011<br> <a href="http://www.cherryarts.org" rel="nofollow" target="_blank">http://www.cherryarts.org/</a><br><br> </h6> </div> </div> <div id="footer"> <p>Viviana Santamarina - vivitus@gmail.com - 415-552-3078</p> </div> </div> </body> </html> I'd appreciate any thoughts on how I can have the thumbnails in the footer DIV change the picture in the "portfolio" div just like my virtualpaginate numbers currently do. Thank you in advance!! Hard To Explain What I need. Looking for javascript, to do what i've hap-hazardly slapped together he I'd like to do this without having to reload a page or create a new page for each image. http://www.samivesphotography.com/redes/portraits.html Specifically the switching of the main image by the thumbnails. The difference in what i've seen online, is that i'm actually using them as a cell background. -Sam I am looking for tutorials on creating a slideshow with thumbnails, but i need one where i can put the mouse over the thumbnail depending on the direction i am the mouse the thumbnail will move left or right thanks Hello, I am trying to retrieve a cookie I stored with Perl through javascript. Based on the contents of the cookie, I want the javascript to print/not print an extra link on my page. Below is the code, in Perl, I am using to store the cookie. In the Perl forum I was told to post in here for the javascript help. The basic idea is that if the cookie has a "Role" of "Super," the ADMIN link displays on the page. If the role doesn't have "Super," the link is hidden. Any help you could offer would be greatly appreciated. Thanks a lot. Code: #!/usr/local/bin/perl # This page was created and worked on by 2/C Collard, 2/C Waymouth, 2/C Troisi, and 2/C Cunha #source: http://forums.speedguide.net/showthread.php?t=190821 # PERL MODULES WE WILL BE USING use DBI; use DBD::mysql; use CGI qw( :standard ); use CGI::Carp qw(fatalsToBrowser); #print "Content-type: text/html \n\n"; $userPassed = param("userID"); # CONFIG VARIABLES $platform = ""; $database = ""; $host = ""; $port = ""; $tablename = ""; $user = ""; $pw = ""; # DATA SOURCE NAME $dsn = "dbi:$platform:$database:$host:$port"; # PERL DBI CONNECT $connect = DBI->connect($dsn, $user, $pw) or die "Connection Error: $DBI::errstr\n"; # PREPARE THE QUERY my $query = "SELECT * FROM $tablename WHERE User = '$userPassed'"; my $query_handle = $connect->prepare($query); #print ($query); # EXECUTE THE QUERY $query_handle->execute(); while (@row = $query_handle->fetchrow_array) { $roleIn = "$row[2]"; #print ("$roleIN"); } $query = new CGI; # create a new CGI object $cookie = $query->cookie ( -name => 'Role', -value => '$roleIn', -path => '/', -expires => '+60m'); $location = ''; print $query->header(-cookie=>$cookie); print qq{<meta http-equiv="REFRESH" content="0;URL=http://www.togoto.com">\n}; # HTTP HEADER #print( header() ); #print ( start_html() ); # Print XHTML footer #print ( end_html() ); Hello there. I'm having trouble with cookies. I have a bunch of links that when clicked on, create a cookie. For each link I need to be able to save that cookie value to the main cookie name. Here is the click function I'm using to create the cookie: $j('a.createCookie').click(function(e) { var cookieName = "InsightsCookie"; var cookieValue = $j(this).attr("id"); $j.cookie(cookieName, cookieValue, {expires: 365, path: '/'}); }); The end result would be "InsightsCookie: cookieValue, cookieValue, cookieValue" - where each link clicked on would add a value to InsightsCookie. Any help would be much appreciated. Hi, I need a javascript function to show and allow user to access Browser stored Favorites and Recent History in a web page. Thanks, GravityPush I have garlic.js automatically local storing my radio button value but the onclick function does not run when the page reloads. Is there a way to work around this ??
Reply With Quote 01-15-2015, 11:17 PM #2 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,311 Thanks 82 Thanked 4,754 Times in 4,716 Posts And we are supposed to guess what "garlic.js" is doing? Or what it is? And do you really mean that the onclick event handler does not work? Or do you mean that the radio buttons are set to a different state but the click() for the chosen button is not executed? That is, it is not the onclick that is missing, it is the click ?? I'm using a image of the day script and my pictures will not be located at the site where the code will be. Code: images[0] = "<img src='yourimage.jpg'>" Do I/can I use the link such as <a href="http://www.sample.com/mphases.htm"> right where (yourimage) is, in between the quotes to link to an offsite picture? Could someone retype this snippet of code showing how it would look for me? Thanks I am working on a page where the user will select a location from a dynamically generated dropdown list. I was able to create the php multidimensional array (tested and working) from a MySql database using the users information at login, but I'm having problems converting it to a javascript multidimensional array. I need to be able to access variables that I can pass to a number of text fields within an html form. For instance, if a user belongs to a company with multiple addresses, I need to be able to let them select the address they need to prepopulate specific text fields. php array creation: Code: if ($row_locations) { while ($row_locations = mysql_fetch_assoc($locations)) { $mail[$row_locations['comp_id']]=array('mailto'=>$row_locations['mailto'], 'madd'=>$row_locations['madd'], 'madd2'=>$row_locations['madd2'], 'mcity'=>$row_locations['mcity'], 'mstate'=>$row_locations['mstate'], 'mzip'=>$row_locations['mzip'], 'billto'=>$row_locations['billto'], 'badd'=>$row_locations['badd'], 'badd2'=>$row_locations['badd2'], 'bcity'=>$row_locations['bcity'], 'bstate'=>$row_locations['bstate'], 'bzip'=>$row_locations['bzip']); } } javascript function - this should create the array and send variables to text fields. Code: function updateAddress() { var mail = $.parseJSON(<?php print json_encode(json_encode($mail)); ?>); { if (comp_id in mail) { document.getElementById('mailto').value=mail.comp_id.mailto.value; document.getElementById('madd').value=mail.comp_id.madd.value; document.getElementById('madd2').value=mail.comp_id.madd2.value; document.getElementById('mcity').value=mail.comp_id.mcity.value; document.getElementById('mstate').value=mail.comp_id.mstate.value; document.getElementById('mzip').value=mail.comp_id.mzip.value; } else { document.getElementById('mailto').value=''; document.getElementById('madd').value=''; document.getElementById('madd2').value=''; document.getElementById('mcity').value=''; document.getElementById('mstate').value=''; document.getElementById('mzip').value=''; } } } Where is this breaking? Thanks in advance. I have the following array that contain the people who are on off on certain time: Code: var all = [ ["1234", "Jim", "2011-10-23 00:00:00", "2011-10-25 07:00:00"], ["1235", "Jack", "2011-10-21 00:00:00", "2011-10-21 08:00:00"], ["1236", "Jane", "2011-10-11 00:00:00", "2011-10-11 00:30:00"], ["1237", "June", "2011-10-20 00:00:00", "2011-10-20 12:00:00"], ["1238", "Jill", "2011-10-14 00:00:00", "2011-10-14 11:00:00"], ["1239", "John", "2011-10-16 00:00:00", "2011-10-16 10:30:00"], ["1240", "Jacab", "2011-10-19 00:00:00", "2011-10-20 08:30:00"] ]; The above array, I wish to use javascript to insert into the FullCalendar (http://arshaw.com/fullcalendar/). I notice that the only way seems to be using the FullCalendar array style (or structure) as follows: Code: $('#calendar').fullCalendar({ events: [ { title : 'event1', start : '2010-01-01' }, { title : 'event2', start : '2010-01-05', end : '2010-01-07' }, { title : 'event3', start : '2010-01-09 12:30:00', allDay : false // will make the time show } ] }); So, the question is: How do I insert my array to match with the FullCalendar array? cause FullCalendar array had a different array structure from my array - and I don't think so that I can write in this way: Code: $('#calendar').fullCalendar({ events:all }); Appreciate any help provided. Hey guys, I'm hoping this is possible or that there is an easier way to do this. I'm having an issue with displaying data from one array that contains information about users in a table that is controlled by a different array. Is it possible to do this or is this use of arrays to display the data the wrong approach? The table is located on one webpage, I simply want to extract one piece of information that I have placed in the initial array as part of the login script that contains user information (for validation for login etc) and display it in a table on the new webpage that is opened as a result of successful validation of the user details. I'm completely stumped and after many attempts I just can't seem to get it to work. |