i have a table of images, with onmouseover,onmouseout and click events. The user can select and deselect an image. When an image is selected, the image scr changes.
Then the user can confirm his selections and redirect to another page for the checkout process. When he returns to the first and initial page, i want his selections to have a different image (lets say confirmed.gif).In other words to save his selections in a cookie and return them by changing the images so that they wont be available for selection.
In order to find which images are selected and store them in an array i can use the following loop:
function getSelected(){
var myArray = [];
var images = document.getElementsByTagName("img");
for (i=0;i<images.length;i++){
[Code]....
How i can save that array with the images tittles in a cookie, so that when the initial page loads i can find which images to change and then change the image.src to confirmed.gif ?
Can I make a list of hyperlinks that users can customize and save as a cookie by clicking a button and automatically retrieve the cookie so it remembers their list next time? This is kind of what I want to do:
I have this in a FORM tag: OnSubmit="return SendForm(this);
to save the content of the form in a cookie. But I need to save it a on windows print, where I reload the form with a css for print. Therefore the form must be filled in again from the cookie. But how do I save the form without submitting ?
I retrieve the saved data with: onLoad="OldForm(document.forms(0));
I found this script online that lets users on an iPhone drag boxes around the screen. The problem is that when you reload the page, the boxes are in different positions than what they were before the reload. Like, you would drag the boxes around and then reload the page, but the boxes would be in the default locations. I want the boxes to stay in the same spot that they were the previous time they moved them. Does that make sense? Anyways, here's the example I found online: [URL] Only works on iPad/iPhone/iPod Touch.
I have an image switcher script setup. Its very basic and changes the image displayed on click of a link. Here is what I currently have:
Javascript:
<script type="text/javascript"> function changeIt(imageName,objName) { var obj = document.getElementById(objName);
[Code]....
Its very basic but does what I want. What I'm attempting to do is store the image selected as a cookie so that when users refresh/navigate to other pages the image stays to the one they selected.
I am using a script found on Dynamic Drive and edited it a bit to fit my needs. Its a script to toggle a content area and at the same time display a + or - depending on if the content is displayed or not. The problem, the state of the content area is saved in a cookie, but the +/- state is not. I have gone over some cookie tutorials and looked through the forums, but I just couldnt figure how to edit the code to make the +/- save state. Code:
I'm trying to read a cookie that I've set with php with javascript. The cookie is for storing the username when logging in to a site. If the cookie has been set I want the focus in the inline popup to target the password field so that the user doesn't have to tab down from the username field of the login form.
The php script stores the cookie perfectly: if (isset($_POST['remember'])){ $expire = time()+60*60*24*30; setcookie("login_username", $username, $expire); echo $_COOKIE['login_username']; } else { if (isset($_COOKIE['login_username']) || isset($_COOKIE['password'])){ $expire = time()-3600; setcookie("login_username", "", $expire); }}
The javascript: if (targetfocus == 'login_username'){ alert(readCookie('login_username')); if (readCookie('login_username') == 'username'){ targetfocus = 'password'; }} $("#"+targetfocus).focus(); ... function readCookie(name) { var cookieName = name + "="; var cookieArray = document.cookie.split(';'); for (var i = 0; i < cookieArray.length; i++){ var cookie = cookieArray[i]; while (cookie.charAt(0)==' '){ cookie = cookie.substring(1,cookie.length); }if (cookie.indexOf(cookieName) == 0){ return cookie.substring(cookieName.length,cookie.length); }return null; }}
But when trying to read the cookie in the javascript code I receive null when I put an alert to the code. Why won't the javascript find the cookie? Is it because I'm running the site localhost on my laptop? Does that have an effect on cookies?
I want to detect if a user is coming from a given url. If he is, the url is stored in a cookie and a div is displayed in top of the pages when he navigates around the site.
how to save data like : position, style, etc in a cookie, using jquery, and then to load that data back if i need to.
I've been researching and i found some plugins but i cant put the script together,
i would like a simple working example or some good documentation because from what i read it doesn't seem to be very hard, but on every forum I've been that talks about cookie setup there is not so much info
I can't figure out why I am not able to read the cookies sitewide, maybe it is the way I am setting the cookie but the cookie looks to be set correctly in the Firefox browser.
On the page that I set the cookie, it works. I can read the cookies I set on the same page as well.
If I move to another page to view the cookies it gives an undefined value when using the getCookie function.
IF the problem lies in the getCookie function, please explain the code a little to me so I can get an understanding what I missed.
I have a script that i need to read the ip from a visitor and set a cookie, so the script will never be executed again for that particular ip address.
Right now i'm having problems with the current cookie set of my script, i can't seem to make it not appear again after it's executed (which is my goal). That's why i want to try using an IP cookie, and see if that works.
I've been researching cookies a bit, and I attempted to create a function that if you select a background name from a drop down list or anything for that matter, it will save the background in the cookie, and display it in a div background for later use. Now I can't quite figure out why there is a problem with this script, but the error checker tells me there is.
Heres the code: <script type="text/javascript"> //Get Cookie function get_cookie(Name) { var search = Name + "=" var returnvalue = ""; if (document.cookie.length > 0) { offset = document.cookie.indexOf(search) // if cookie exists if (offset != -1) { offset += search.length // set index of beginning of value end = document.cookie.indexOf(";", offset); .....
I have lots of links in the page, click each one addClass 'voted' to this link. then save the effection into cookies. so that next time refresh web browser, it will save the addClass event. I use jquery cookie here: [URL] My code here, but it will only save 1 cookie. I mean if I clicked link 1, link 2. it always remember the last click. refresh the web browser. only link 2 addClass 'voted'. link1 missed addClass event. so how to save multiple cookie for every link?
On one of my sites, I have a reather involved page (searchable map). When the person leaves the page then all the AJAX generated information is lost. Is there a way that I can retain all this data in a cookie or so or how would you recommend I saved all the users information (perhaps using a database on the serverside).
I have a Javascript used to adjust the fontsize on a webpage. This JS does not create a cookie to save the users setting, so if he goes to another page on the site, the default font size is shown.This is the JS;
Code: var min=8; var standard=11; var max=15;[code].......... What I need, is some code that will create a cookie, so that the users settings will be used throuout his whole visit.
I can't find any javascript that reads and writes cookies with keys, so that it is compatible with ASP (I want to read and write cookies from both javascript and ASP)
for example in ASP: <% Response.Cookies("user")("firstname")="John" Response.Cookies("user")("lastname")="Smith" Response.Cookies("user")("country")="Norway" Response.Cookies("user")("age")="25" %>
I'm looking for javascript code that can read that information.
My requirement: Each time a visitor arrives at a specific webpage i want the main image on the page to be different, or more specifically, one of 6 images which will be shown in rotation. Solution: Set a cookie. Each time the visitor access the page read the cookie and display the corresponding image. Then increment the value and rewrite the cookie, so that next time they'll see the next image in sequence. NB: if the cookie does not exist (first timer) or is at 6, then the value is set to zero (and then incremented).
Problem: Can't get my coding to work. Specifically it just doesn't do anything - no error message, no cookie written. I'm a very novice scripter, as in I've cobbled the coding together from bits off the net that i think i've managed to grasp some kind of an understanding of. Very suck it and see - so far lots of sucking and no seeing!
I have an external file, TestVar.js with a single line. NewsA("This is a test.","test.pdf","TEST")
Within my HTML I wish to use the array variables from TestVar.js, but can't seem to get them loaded for use. The following is what I have, but doesn't work. If I directly place the NewsA array in the script instead of trying to call it from the js it works just the way I want it, but I really need the external file. What am I doing wrong? Code:
While writing a look up for internet terms script for a site, I found the script will not read the second value in this array, I could make wl[1] a null value but would like to know what is happening if possible. All of the other elements seem to be ok!
function search(){ wl = new Array() wl[0]="applet - An Applet is a small application etc"; wl[1]="Bug? - Null but why"; wl[2]="cgi - CGI or Common Gateway Interface allows etc"; wl[3]="browser - A Browser is etc."; myWord=document.theForm.txtWord.value; myWord = myWord.toLowerCase(); for(c=0; c < wl.length; c++){ currentWord = wl[c].split(" "); alert(c + " MyWord " + myWord); alert(c + " Current " + currentWord[c]);// The alert box = 'Current -' when wl[1] is read. } }//end of function
I have the following down code to display xy of image pixel I want to add an event ( onclick ) to save the current xy to an array after that I want to add a button to display the previous saved xy in this array...any clue??
<html> <head> <script> function showPosition1(evt,elImage)
What i want to know is how to read the value stored in an array to a textbox though I have a second array which is contianed in dropdowns with a for loop iterating
ie item and price arrays
So i want it if item [position] then price [position] is called to the textbox how do i do this so that it iterates through the values using a for loop as i am meant to iterate through and not hardcode in values.
I need to read a files contents to an array so that i can check which lines of the file i need to write back. im not very good with arrays and haven't had any luck so far.