JavaScript - Cookie With Multiple Values Stored
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. Similar TutorialsI had post this problem before, dealing with the shopping cart application. The application so far does everything that i would like it to do. I'm able to store and retrieve the cookies. But right now, my problem is extracting the individual values from the cookies and placing them into a table i have created. This is the format of the cookie when retrieved. ItemName = quantity$price. what i am trying to do is retrieve the quantity and price values from the cookie, and display that data into my table. the cookie is being created in my store page, and then retrieved and displayed in my cart page. here is the code for my store page store.html 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" xml:lang="en" lang="en"> <head> <title> Store </title> <h1> My store </h1> <script type="text/javascript"> function retr(circle) { var cke = document.cookie.split(';'); var nameCk= name + "="; for(var i=0; i < cke.length; i++) { var c = cke [i]; while (c.charAt(0)==' ') c = c.substring(1, c.length); if (c.indexOf(nameCk) == 0) return c.substring(nameCk.length, c.length); } return null; } function createCookie() { var exdate = new Date(); exdate.setDate(exdate.getDate() +10); if (document.getElementById("circle").checked) { document.cookie = "Circle=" + document.getElementById ("quantity1").value + document.getElementById("price1").value + ";expires="+exdate.toGMTString(); } } function retrieve() { if (document.getElementById("circle").checked) { document.getElementById("ret").value = document.cookie; } } function Calc() { var fpri = document.getElementById("price1").value; var pri = fpri.substr(1); var qty = document.getElementById("quantity1").value; var spri = document.getElementById("price2").value; var pri2 = spri.substr(1); var qty2 = document.getElementById("quantity2").value; if (document.getElementById("circle").checked) { document.getElementById("total").value ='$' + Number(pri) * Number(qty); } else document.getElementById("total").value = '$' + Number(pri2) * Number(qty2); } </script> </head> <body> <table border = "1"> <tr> <td> <input type="checkbox" id="circle" /> Circle </td> <td> <img src="circle.jpg"> </img> </td> <td> Price: <input type="text" size="4" value = "$10.00" id="price1" name = "price1" /></td> <td> Quantity: <input type="text" size = "4" id="quantity1"/></td> </tr> <tr> <td> <input type = "checkbox" id="stickman" /> Stickman </td> <td> <img src = "stickman.gif"> </img> </td> <td> Price: <input type="text" size="4" value = "$5.00" id="price2" /> </td> <td> Quantity: <input type="text" size="4" id="quantity2" /> </td> </tr> </table> <br /> <input type = "button" value = "Add to cart" onclick="createCookie()"> <br /> <br /> <a href ="cart.html" > View Cart </a> <br /> <input type = "text" size = "8" id = "total" readonly = "readonly" /> Total <br /> <input type = "button" id = "calcu" value = "calc" onclick = "Calc ()" /> <input type = "button" value = "retrieve" onclick = "retrieve()" /> <input type = "text" readonly = "readonly" name = "ret" id = "ret"/> </body> </html> the calculate and retrieve buttons, and the readonly text boxes are there just so i know the cookie is being stored and retrieved, and that i'm able to get the total, which will be displayed on my cart page. here is the code for my cart page cart.html Code: <html> <head> <title> Cart </title> <h1> My cart </h1> <script type = "text/javascript"> function retr(circle) { document.getElementById("q2").value = document.getElementById("quantity1").value } function retrieve() { var quvalue = retr("circle") if (quvalue != false) { document.getElementById("q2").value = quvalue } document.getElementById("ret").value = document.cookie; } </script> </head> <body onload = "retrieve()"> <table border = "1"> <td>Stickman </td> <td><input type = "text" size = "8" id = "q2" readonly = "readonly" /></td> <td id ="p1"> price per </td> <td id ="t1"> total </td> <tr> </tr> <td> Circle </td> <td> quantity order </td> <td> price per </td> <td> total </td> <tr> </tr> <td colspan = "3"> TOTAL: </td> <td> total price </td> </table> <br /> <br /> <input type ="text" id = "ret" readonly = "readonly" /> <br / > <br /> <input type = "button" value = "Checkout"> <br /> <br /> <a href = "store.html" > Continue Shopping </a> </body> </html> the values that are supposed to be retrieved in the table are invoked using the onload event attribute which is suppose to call the retrieve() function. I need help in creating a multiple value cookie when the user clicks the Add to cart input button. Here is the portion of code from the html page that creates the inventory item display and the Add to cart button. There are six of these on the page: Code: <div id="inventoryspread"> <div class='productBoxInvUL'> <script type:"text/javascript"> document.write("<img src="+"'"+"images/"+arrImage[0]+"'"+"align='left'/>"+ "<p><br/><span class='invName'>"+arrName[0]+"</span></p>"+ "<p>"+arrDescription[0]+"</p>"+ "<p>Item# "+arrItem[0]+"<br/>"+ "<span class='invPrice'>"+arrPrice[0]+"</p>"); </script> <input type="button" value="Add to Cart" onclick='createCookie("name, value, 7", prompt("cookie created"))' /> </div> And here is a portion of the array that fills it: Code: var arrItem = new Array(); var arrName = new Array(); var arrDescription = new Array(); var arrPrice = new Array(); var arrImage = new Array(); arrItem[0]= "FE100"; arrName[0]= "Blacktop Jazzmaster"; arrDescription[0]= "Monster dual-bucker tone. Vintage style alnico humbucking pickup, single coil, skirted black amp knobs, and 3-way toggle switch. Alder body, Maple neck, Rosewood fretboard, 21 medium jumbo frets, gloss urethane finish and nickel/chrome hardware."; arrPrice[0]= "$699.00"; arrImage[0]= "FE100.png"; arrItem[1]= "FE200"; arrName[1]= "Roland-Ready Stratocaster"; arrDescription[1]= "Time-tested Fender tone, timeless styling, 3 single-coil pickups, synchronized tremolo, high-mass bridge block, shielded body cavities and medium jumbo frets. Built-in Roland GK-2A pickup system, tinted neck, parchment pickguard and control knobs, and a '70s-style logo."; arrPrice[1]= "$1,019.00"; arrImage[1]= "FE200.png"; arrItem[2]= "FA100"; arrName[2]= "CD220SCE Exotics "; arrDescription[2]= "Exotic and beautiful with rich tone, laminated burl ash back and sides, with a solid spruce top. Fender-designed dreadnought body, X-bracing, and die-cast tuners. Cutaway body design with rosewood bridge featuring a compensated bone nut"; arrPrice[2]= "$629.00"; arrImage[2]= "FA100.png"; arrItem[3]= "FA200"; arrName[3]= "Dick Dale Mailbu SCE"; arrDescription[3]= "Thin folk body design, laminated spruce top, laminated mahogany back and sides, scalloped X-bracing providing well balanced tone. Maple neck, rosewood compensated bridge and fretboard, vintage-style Fender tuners, and a surfin' red paint job on the top and back"; arrPrice[3]= "$849.00"; arrImage[3]= "FA200.png"; arrItem[4]= "FB100"; arrName[4]= "Standard Precision Bass"; arrDescription[4]= "Sound, look, and feel today's bass players demand. Classic P-Bass old-school design. Contemporary features and refinements. Alder body and a split single-coil pickup, this classic electric bass guitar lives up to its Fender legacy."; arrPrice[4]= "$579.00"; arrImage[4]= "FB100.png"; arrItem[5]= "FB200"; arrName[5]= "Roger Waters Signature Precision Bass"; arrDescription[5]= "Tastefully tailored, black-on-black color scheme, Seymour Duncan Basslines SPB-3 Quarter-Pound split-coil Precision Bass pickup, knurled black control knobs, brass nut, black bridge and strap buttons, vintage '70s-style open-gear chrome tuners."; arrPrice[5]= "$1,199.00"; arrImage[5]= "FB200.png"; arrItem[6]= "GE100"; arrName[6]= "Firebird X Limited Edition"; arrDescription[6]= "Turbo-charged Pure-Analog engine. Hand-applied and unique high-end wood finish. Beautiful, historical and yet contemporary and unique. Limited run of just 1,800 units. It is sure to become a collector classic."; arrPrice[6]= "$5,569.00"; arrImage[6]= "GE100.png"; The cookie only needs to include the Item#, Name and Price of each item to populate a shopping cart page. This is only a small student project and is client side only using javascript. Thank you for any help we can get on this. Hi all, I have to check for several possible values of a variable and I currently do it like so: Code: (SHIP_TYPE == "M" || SHIP_TYPE == "S" || SHIP_TYPE == "X") But this seems overly manual to me. I'm imagining something like the SQL "IN" function: Code: SHIP_TYPE IN ('M','S','X') Does such a thing exist in JavaScript, or do I need to write my own function? Hi, I am setting up an email form & i would like the subject field to hold multiple values, the forrm will be something like this: Name:Mr A Date: 01/01/01 Reason:Football I want the form to send an email without opening an email client & I would like the subject field to look like this: Subject: Mr A, 01/01/01, Football or Subject Mr A - 01/01/01 - Football Can anyone tell me if this is possible, if if is can you please point me in the right direction. Thanks Hi, I'm having problems getting the values of selected checkboxes and outputting them to a textarea. This seems like quite a simple thing to do but its causing me a lot of bother! I am using a mixture of JavaScript and jQuery to find a solution to this. Code: <h2>Booking Form</h2> <form name="booking"> Please choose the days that would suit your visit: <br/> <input type="checkbox" name="days" value="Monday">Monday<br/> <input type="checkbox" name="days" value="Tuesday">Tuesday<br/> <input type="checkbox" name="days" value="Wednesday">Wednesday<br/> <input type="checkbox" name="days" value="Thursday">Thursday<br/> <input type="checkbox" name="days" value="Friday">Friday<br/> </form> <textarea id="output"> </textarea> Code: var values = $("#days").val() || []; $("p#ss").html("<strong>Checked values:</strong> " + values.join(", ")); //This just outputs "Checked values:" to the paragraph 'ss' that I created just to test it this way. Help with this would be appreciated. I have the following script that currently returns 4 of the same images. I can't wrap my head around how to get it to return 4 random images (out of the 7 in this example)? Also the links aren't working? --- Code: var imagenumber = 7 ; var randomnumber = Math.random() ; var rand1 = Math.round( (imagenumber-1) * randomnumber) + 1; images= new Array images[1] = "image1.jpg" images[2] = "image2.jpg" images[3] = "image3.jpg" images[4] = "image4.jpg" images[5] = "image5.jpg" images[6] = "image6.jpg" images[7] = "image7.jpg" var image = images[rand1] links= new Array links[1] = "link1.html" links[2] = "link2.html" links[3] = "link3.html" links[4] = "link4.html" links[5] = "link5.html" links[6] = "link6.html" links[7] = "link7.html" var link = links[rand1] document.write('<div id="image-1"><a href="' + link + '"><img src="' + image + '"></a></div><div id="image-2"><a href="' + link + '"><img src="' + image + '"></a></div><div id="image-3"><a href="' + link + '"><img src="' + image + '" border="0"></a></div><div id="image-4"><a href="' + link + '"><img src="' + image + '"></a></div>') --- Any help would be greatly appreciated! Hey CF. I'm not great with JS, but I'm trying to build something pretty simple and even that's out of my league. I have a layout with multiple fields that need to be filled randomly from an array on click. I have an array with a bit of jQuery that randomly reloads one field on click, but I need multiple fields filled at once from the same item in the array. Code is below. I grabbed it from a tutorial somewhere, and have made some modifications. Code: <Script> $(document).ready( function() { var foodArray = [ '1', '2', '3', '4', '5' ]; $('.foodtype').loadText( foodArray, 10000 ); // ( array, interval ) }); // custom jquery plugin loadText() $.fn.loadText = function( foodArray, interval ) { return this.each( function() { var obj = $(this); obj.fadeOut( 'slow', function() { obj.empty().html( random_array( foodArray ) ); obj.fadeIn( 'slow' ); }); timeOut = setTimeout( function(){ obj.loadText( foodArray, interval )}, interval ); // reload random text (if not animated) -- entirely optional, can be removed, along with the reload link above (<a href="javascript:;" id="text-reload"><em>randomize</em></a>) $("#text-reload").click( function(){ if( !obj.is(':animated') ) { clearTimeout( timeOut ); obj.loadText( foodArray, interval );} // animation check prevents "too much recursion" error in jQuery }); }); } //public function function random_array( aArray ) { var rand = Math.floor( Math.random() * aArray.length + aArray.length ); var randArray = aArray[ rand - aArray.length ]; return randArray; } </script> That outputs one of the array items into a <span class="foodtype">. What I need is another value next to say "1", eg '1, Blue' and print "Blue" to another span. Can anyone help? The other issue I have is the divs are snap resizing, is there a way set them to animate smoothly? The total height will be variable depending on the combinations that display. Cheers guys, hope someone can help. Hi everyone, I am using a jQuery cookie script to set the cookie of some elements on my website. One of the problems is that I need the cookie to not expire after one day, I need it to expire after a while (I'm going to start off with a year). Here's my script, the red part is what I've been editing. Code: /** * Cookie plugin * * Copyright (c) 2006 Klaus Hartl (stilbuero.de) * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * */ /** * Create a cookie with the given name and value and other optional parameters. * * @example $.cookie('the_cookie', 'the_value'); * @desc Set the value of a cookie. * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secu true }); * @desc Create a cookie with all available options. * @example $.cookie('the_cookie', 'the_value'); * @desc Create a session cookie. * @example $.cookie('the_cookie', null); * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain * used when the cookie was set. * * @param String name The name of the cookie. * @param String value The value of the cookie. * @param Object options An object literal containing key/value pairs to provide optional cookie attributes. * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object. * If a negative value is specified (e.g. a date in the past), the cookie will be deleted. * If set to null or omitted, the cookie will be a session cookie and will not be retained * when the the browser exits. * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie). * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie). * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will * require a secure protocol (like HTTPS). * @type undefined * * @name $.cookie * @cat Plugins/Cookie * @author Klaus Hartl/klaus.hartl@stilbuero.de */ /** * Get the value of a cookie with the given name. * * @example $.cookie('the_cookie'); * @desc Get the value of a cookie. * * @param String name The name of the cookie. * @return The value of the cookie. * @type String * * @name $.cookie * @cat Plugins/Cookie * @author Klaus Hartl/klaus.hartl@stilbuero.de */ jQuery.cookie = function(name, value, options) { if (typeof value != 'undefined') { // name and value given, set cookie options = options || {}; if (value === null) { value = ''; options.expires = -1; } var expires = ''; if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { var date; if (typeof options.expires == 'number') { date = new Date(); date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000 * 365)); } else { date = options.expires; } expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE } // CAUTION: Needed to parenthesize options.path and options.domain // in the following expressions, otherwise they evaluate to undefined // in the packed version for some reason... var path = options.path ? '; path=' + (options.path) : ''; var domain = options.domain ? '; domain=' + (options.domain) : ''; var secure = options.secure ? '; secure' : ''; document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); } else { // only name given, get cookie var cookieValue = null; if (document.cookie && document.cookie != '') { var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) { var cookie = jQuery.trim(cookies[i]); // Does this cookie string begin with the name we want? if (cookie.substring(0, name.length + 1) == (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } } return cookieValue; } }; hello everybody! this is my first atempt in writing javascript and i have a problem which I have no idea how to solve. I want to take the values from several dropdown forms and make some calculations whit those in order to display a number. Unfortunately the script responts in a way that i cannot identify what is happening. this is a shorten example of my script. Code: <html> <head> <script type="text/javascript"> function calcul() { var pcno = document.plithospc.listplpc.value; var ndno = document.plithosnd.listplnd.value; var hotline = document.hotlform.listhotl.value; var sumhotline = 0; if (hotline == 2) { sumhotline = 8*(1+0.5*pcno) + 2*(1+0.5*ndno); } else if (hotline == 3) { sumhotline = 16*(1+0.5*pcno) + 4*(1+0.5*pcno); } else { sumhotline = 0; } document.write(sumhotline); </script> </head> <body> <FORM NAME="plithospc"> <SELECT NAME="listplpc"> <OPTION SELECTED="SELECTED" VALUE=0>choose one</OPTION> <OPTION VALUE=1>-1-</OPTION> <OPTION VALUE=2>-2-</OPTION> <OPTION VALUE=3>-3-</OPTION> </SELECT> <FORM NAME="plithosnd"> <SELECT NAME="listplnd"> <OPTION SELECTED="SELECTED" VALUE=0>choose one</OPTION> <OPTION VALUE=1>-1-</OPTION> <OPTION VALUE=2>-2-</OPTION> <OPTION VALUE=3>-3-</OPTION> </SELECT> <FORM NAME="hotlform"> <SELECT NAME="listhotl"> <OPTION SELECTED="SELECTED" VALUE=0>choose one</OPTION> <OPTION VALUE=1>1st selection</OPTION> <OPTION VALUE=2>second selection</OPTION> <OPTION VALUE=3>third selection</OPTION> </SELECT> <button type="button" onclick="calcul()">click me</button> </body> does anyone knows how to fix this? thanks in advance print "<Font face=\"calibri, Arial\"><table id=\"rnatable\" border=2px width=100%>"; print "<th></th>"; print "<th>a</th>"; print "<th>b</th>"; print "<th>c</th>"; print "<th>d</th>"; print "<th>e</th>"; print "<th>f</th>"; print "<th>g</th>"; while($array = mysql_fetch_array($sql_query)) { $id=$array['a']; print "<tr id=\"newtr\">"; print "<td><input id=\"check\" type=\"checkbox\" name=\"keyword[]\" value=\"$id\" ></td>"; print "<td>".$array['a']."</td>"; print "<td>".$array['b']."</td>"; print "<td>".$array['c']."</td>"; print "<td>".$array['d']."</td>"; print "<td>".$array['e']."</td>"; print "<td>".$array['f']."</td>"; print "<td> <a href=\"http://localhost/rnasearch/retrieve.php?a=$id\">bla</a> </td></tr></font>"; } print "</table>"; } this is part of a php searchengine script that i wrote to retrieve data from a database and as you can see the last column that is g contains a link which when clicked takes the user to the second php script which retrieves additional information of that entry, but this is done for only single entries so as you can see i introduced checkboxes so that the user can check any number of checkboxes and retrieve information as per their wish now to do this i created a <input type=text where i want the value of these checkboxes i.e. $id to be posted in a delimited format so that the user can then click the corresponding button and retrieve the information this is the code <div id="floatMenu"> <ul class="menu1"> <center><li><form name="senddata" method="POST" action="http://localhost/retrieve.php" style="display:inline;"><input id="fasta" type="text" class="multitext"><input name="Fasta" type="Submit" value="Retrieve Fasta"></form> this is a css floating menu....so far so good....everything went fine.... after this i had to write a javascript to do this and i've been stuck there searching forums for the last 4 days! this is the javascript i found from somewhere which came close to doing wht i wanted it to do window.onload = function () { var cb = document.getElementById('check'); var fasta = document.getElementById('fasta'); cb.onclick = function () {fasta.value = cb.value + ","; };}; this script only sends the value of the first checkbox in the table, the others are not found by it, mind you its not the first checkbox selected its the first checkbox that is present in the table how can i resolve this problem so that even if i have n number of checkboxes in my table, if the user chooses to do so they can retrieve n number of information....please help i've almost lost hope in this! 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> 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() ); 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 ?? 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 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> 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 Hi gud mng, I have one problem... How to process textbox values/ call textbox values in JS through a Java program. My text box values are dates. I have to process these dates. Like in online banking we select day to know our transactions. After submitting we get results. remember my files are in my directory only. No need of database. My files are look like 20100929, 20100930, 20101001 For epoch_classes.js, epoch_styles.css u can download coding from this link : http://www.javascriptkit.com/script/...ch/index.shtml Code: Code: <html> <table width="900" border="0" cellpadding="10" cellspacing="10" style="padding:0"> <tr><td id="leftcolumn" width="170" align="left" valign="top"> <div style="margin-left:0px;margin-top:0px"><h3 class="left"><span class="left_h2">Select Option</span></h3> <a rel="nofollow" target="_top" href="day_wise.htm" >Day-wise</a><br /> <br /> <a rel="nofollow" target="_top" href="between.htm" >Between Days</a> <link rel="stylesheet" type="text/css" href="epoch_styles.css" /> <script type="text/javascript" src="epoch_classes.js"></script> <script type="text/javascript"> var cal1, cal2; window.onload = function () { cal1= new Epoch('epoch_popup','popup',document.getElementById('popup_container1')); cal2= new Epoch('epoch_popup','popup',document.getElementById('popup_container2')); }; /*............*/ function confirmation(f) { var startdate = f.fromdate.value var enddate = f.todate.value var myday=new Date() var yr=myday.getFullYear() var mn=myday.getMonth()+1 var dt=myday.getDate() var today="" var present, ys, ms, ds, ye,me,de, start, end if(mn < 10) { mn = "0" + mn } if(dt <10) { dt = "0" + dt } today= yr + "/" + mn + "/" + dt present=yr + "/" + mn + "/" +dt if (today < startdate ) { alert (" Start date should not be exceed to-day's date " + present ) startdate.focus() return false } if (today < enddate ) { alert (" End date should not be exceed to-day's date " + present ) enddate.focus() return false } if (today == startdate ) { alert(" You are selected to-days date as Starting day" ); } var answer = confirm("Do you want to continue ?") if (answer) { if( startdate < enddate) alert("Dates between " + startdate + " to " + enddate + " are confirmed" ) else alert("Dates between " + enddate + " to " + startdate + " are confirmed" ) } else { alert("Date not confirmed") window.location="to_date.htm"; } ys= startdate.substring(0,4); ms= startdate.substring(5,7); ds= startdate.substring(8,10); start=ys + "" + ms + "" +ds ye= enddate.substring(0,4); me= enddate.substring(5,7); de= enddate.substring(8,10); end=ye + "" + me + "" +de } /*.......................................................*/ </script> <div style="margin-left:100px;"> <body> <style type="text/css"> #conf { margin-left:115px; } </style> <td align="left" valign="top"> <table width="100" border="0" cellpadding="0" cellspacing="0"> <td style="padding-top:0px"> </table> <h4>From Date</h4> <form name= "formbet" id="placeholder" method="post" action="#" > <input id="popup_container1" type="text" name= "fromdate" maxlength="10" size="20"/> <td align="left" valign="top"> <table width="300" border="0" cellpadding="0" cellspacing="0"> <td style="padding-top:20px"> <h4>To Date</h4> <input id="popup_container2" type="text" name= "todate" maxlength="10" size="20"/> <br /> <br /> <input id="conf" type="button" onclick="confirmation(this.form)" value="Submit"> </form> </body> </html> In my coding, ys, ms, ds represents year starting, month starting, starting day... ye, me, de represents end... start,end gives file names in the format of yyyymmdd now i want to process files from 20100101 to 20100930 means from date is 2010/01/01 and to date is 2010/09/30 if i press submit button the files from 20100101 to 20100930 are processes here ys=2010 ms=01 ds =01 and ye=2010 me=09 de= 30 For this how do i call these textbox values (from date text box and todate) to another program (java) Thanks in advance. 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? I have a bunch of checkboxes like below that the user can check some or all and click the button and see the values of all the selected checkboxes. How can I do that? Code: <script> function alertValues(){ } </script> <input type="checkbox" class ="normal2" value="131971" name="list[]" > <input type="checkbox" class ="normal2" value="131973" name="list[]" > <input type="checkbox" class ="normal2" value="131975" name="list[]" > <input type="checkbox" class ="normal2" value="131977" name="list[]" > <input type="button" onClick="alertValues()" |