JavaScript - Javascript Session Question
Code:
document.cookie = "score=400"; var x = document.cookie ; alert("Time Up"); window.location.href = "main.php?option=insert_result&result=" + x; In main.php I have a code that will save data on database. My question is why is that it saved something like score=200; PHPSESSID=m5v9qp5c9trcmfi9mso91b7nh5. All I want is 200 to be saved Similar TutorialsHi, I am making a small software which will require activation. My problem is when I activate my software after checking the key through my website I want to enter some information in registry of the user. Now my problem is when I check the value through my website how can I return after verification to the local computer. is it possible if I create a session variable or some other type of variable (not sure what type) and then read that variable on user computer. If that matches I will enter the code in registry. Hello everyone, I have session_start() at the begining of my home page. In my home page I'm calling a fileName.js inside my <head></head> tags. My guestion is... How do I get the session id inside fileName.js? Or is there a way to pass it to fileName.js from the home page(index.html)? Thank You in advance. hello everybody, here I'm asking for help again. sorry for that in advance. anyhow, I have the following code: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link type="text/css" media="screen" rel="stylesheet" href="colorbox.css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="../colorbox/jquery.colorbox.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".example7").colorbox({width:"300px", height:"500px", iframe:true, open: true}); }); </script> </head> <body onload="example7();"> <a class='example7' href="tofes.html"></a> teststestestest </body> </html> I want the lightbox window open only once a day for every unique visitor on my website. I understand I should use some sort of cookie implented, but I dont really understand how to. Thanks in advance, daniel. Hi, I have a website where the user can navigate different categories by tab. The problem is, when they're on a tab other than the default one and they refresh the page or click to another page, it puts them back on the first tab. I know this can be solved by using a session cookie of some type, I just need some help on implementing it into my site. http://www.thatswhyimbroke.com/ - so you can see what i'm talking about. If you look at the different tabs: Price High, price low, food & drink, etc. I want the user to be able to go to one of those, click to page 2 or refresh, and still be on that tab. Any help would be much appreciated! I have a site where i switch between two images using some JavaScript. What I need is to be able to set a session variable or something so that if someone selects shading on or off it sticks to that for the rest of the session. Any idea or even a point in the right direction. Do i need cookies or is there a simple way to do this http://www.tech4t.co.uk/territorymapping/pentagon/ I have been looking all over the web for a solution, because my website displays funky in safari. To fix this i figured i'd tell users that if they are using safari, then using javascript, i could tell them a message. Originally i tried detecting safari then displaying a message. But i couldn't ever find a browser detection for safari. So i thought wait.... If i could: 1. get a javascript alert saying my message. 2. time that message alert frequency by a session, say 10 days? or even every browser session... Then i could solve my problem. However i can't figure out any of this. So if anybody would be willing to help, i'd be very grateful. I have an application that has a menu - one of the choices on that menu is "Contacts" - This menu is controlled by css - I've written a script that will modify the css style setting for "display" and "zindex" for the rule that controls the pull down for contacts - this worked for hover, but I am now trying to change to a click event - I successfully change the rule, but the menu doesn't display - not sure if I'm returning incorrectly form the javascript function or what - here's a code snippet: CSS: Code: .primaryNav .subMenu { background-color: #B0967E; position: absolute; width: 300px; left: 600px; /* 823px - 300px - 20 px + 97px */ padding: 10px; display: none; color: #fff; font-size: 90%; } Javascript: Code: <script type="text/javascript"> function SetDisplayCSS() { var mysheet=document.styleSheets[0]; var myrules=mysheet.cssRules? mysheet.cssRules[0].styleSheet.cssRules: mysheet.imports[0].rules; for (i=0; i<myrules.length; i++){ if(myrules[i].selectorText.toLowerCase()==".primarynav .submenu"){ //find "a:hover" rule targetrule=myrules[i]; alert("Rule is found"); break; } } targetrule.style.display = "block"; targetrule.style.zindex = "10"; alert(targetrule.selectorText); alert(targetrule.style.backgroundColor); alert(targetrule.style.position); alert(targetrule.style.width); alert(targetrule.style.left); alert(targetrule.style.padding); alert(targetrule.style.display); alert(targetrule.style.color); alert(targetrule.style.fontSize); alert(targetrule.style.zindex); return true; } </script> html Code (names have been changed to protect the innocent) - note the onclick event handler for the contacts menu option. Code: <li class="pn test"><a href="#" onclick="return SetDisplayCSS();" name="contacts">Contacts</a> <div class="subMenu"> <table width="100%"> <tbody> <col /> <col align="right" valign="top" /> <tr> <td><a href="mailto:abc@xxxxxxx.com">Service Requests</a></td> <td>555.555.5555</td> </tr> <tr> <td><a href="mailto:me@notreal.com">Bugs Bunny</a><br />Tenant Liaison</td> <td>555.555.555</td> </tr> <tr> <td><a href="mailto:blah@blah.com">blah blah</a><br />Client Services Manager</td> <td>123.456.1234</td> </tr> </tbody> </table> <p><a href="xxxxxxxx.htm" class="more">More Contacts...</a></p> </div> </li> Thanks for any help...... HI Guys!! My name is Megan and I am a college student in need of some JavaScript help for my computer science class!! My professor is making us complete some stupid class project for finals and I can't figure it out! He suggested that we may try to find a JavaScript Website to help us if we have trouble figuring out how to write the code. I have looked and looked and can't find out how to fix my code!! We have to write code to make a slot machine .. I have started the code based on what he gave us and have tried my hardest to figure out how to complete it but I do not know how to finish it. I have the images working correctly (kind of.. the second one seems to have problems loading? I dunno what I did to mess that up) and the counter working, but I need to make it add 13 credits when all 3 images are the same. I added code that I thought would work but it's not for some reason that I can't figure out. It should also pop up an alert screen when all 3 are correct and you win. I guess this would have to be including with the if statement and something like alert('You win 12 credits!!!') Lastly I need to add code that prevents the person from playing when the credit line is 0 (so you can't get - credits!) and I have no idea how to do this. Any help would be greatly appreciated! Here's what I have so far! HI Guys!! My name is Megan and I am a college student in need of some JavaScript help for my computer science class!! My professor is making us complete some stupid class project for finals and I can't figure it out! He suggested that we may try to find a JavaScript Website to help us if we have trouble figuring out how to write the code. I have looked and looked and can't find out how to fix my code!! We have to write code to make a slot machine .. I have started the code based on what he gave us and have tried my hardest to figure out how to complete it but I do not know how to finish it. I have the images working correctly (kind of.. the second one seems to have problems loading? I dunno what I did to mess that up) and the counter working, but I need to make it add 13 credits when all 3 images are the same. I added code that I thought would work but it's not for some reason that I can't figure out. It should also pop up an alert screen when all 3 are correct and you win. I guess this would have to be including with the if statement and something like alert('You win 12 credits!!!') Lastly I need to add code that prevents the person from playing when the credit line is 0 (so you can't get - credits!) and I have no idea how to do this. Any help would be greatly appreciated! Here's what I have so far! Code: <html> <head> <title> Slot Machine</title> <script type="text/javascript" src="http://balance3e.com/random.js"></script> <script type="text/javascript"> function SpinSlots() // Assumes: slot images are in http://balance3e.com/Images // Resultes: displays 3 random slot images { var slot1, slot2, slot3; slot1 = RandomOneOf(['lemon', 'cherry', 'bar']); slot2 = RandomOneOf(['lemon', 'cherry', 'bar']); slot3 = RandomOneOf(['lemon', 'cherry', 'bar']); document.getElementById('slot1Img').src = 'http://balance3e.com/Images/' + slot1 + '.jpg'; document.getElementById('slot2Img').src = 'http://balance3e.com/Images/' + slot2 + '.jgp'; document.getElementById('slot3Img').src = 'http://balance3e.com/Images/' + slot3 + '.jpg'; document.getElementById('credits').innerHTML = parseFloat(document.getElementById('credits').innerHTML) - 1; if (slot1 == slot2 == slot3) { document.getElementById('credits').innerHTML = parseFloat(document.getElementById('credits').innerHTML) + 13; } } </script> </head> <body> <div style="text-align:center"> <p> <img id="slot1Img" border=1 alt="slot image" src="http://balance3e.com/Images/cherry.jpg"> <img id="slot2Img" border=1 alt="slot image" src="http://balance3e.com/Images/lemon.jpg"> <img id="slot3Img" border=1 alt="slot image" src="http://balance3e.com/Images/bar.jpg"> </p> <input type="button" value="Click to Spin" onclick="SpinSlots();"> <p> Credits Remaining: <spin id="credits">20</span> </p> </div> </body> </html> I am a newbie with a newbie question =) I recently took an exam type thing using my Firefox browser (v3.5.3). I still have my browser window open that I used, and when I press the back button on the browser I get a message "To display this page, Firefox must send information that will repeat any action ..." Is there any way (either disk or memory cache) to reload the pages with out having to resend the data, OR is there any way (hex editor) to view the exam (forms) questions?? Just curious, Thanks I'm trying to figure out this question that was assigned to me, as I haven't done alot on javascript before but I've tried to get most of this, I'm just not sure if this is correct. If anybody could help it would be greatly appreciated. The question is as follows: You are provided with a string array called country that contains the name of every country that the Ski Club visits. For example one element of this array might be as follows: country[0] = "Austria" Another array called villages contains strings with information on village names and altitude in a particular country. For example: villages[0] = "Austria:Seefield 850m*"; Write a JavaScript function snowReport(countryIndex) that will use the arrays provided to write a report of all villages that include a given country. The function will be passed an integer representing the index of an element of the country array. A match is found if the country appears in a string (Hint use appropriate JavaScript function to evaluate if a country name is contained in a village string.) All matching villages should be displayed. Output should be displayed in the villages div element you defined in part (a). Output is shown for a search for Austria in Figure 1b. <script type="text/javascript"> function makeArray() { var country = new Array(5); country[0] = "Austria"; country[1] = "Canada"; country[2] = "France"; country[3] = "Germany"; country[4] = "Switzerland"; return country; var villages = new Array(2); villages[0] = "Austria:Seefield 850m*"; villages[1] = "Austria:Ellam 100m"; return villages; } function snowReport(countryIndex){ var string = ""; for (var i = 0; i < countryIndex.length; i++){ str += countryIndex[i] + " "; } return str; } </script> </head> <body> <script> var x = makeArray(); document.write(snowReport(x)); </script> </body> </html> Many thanks! I think this is a pretty easy to fix error made by a newb ( me. Can anyone tell me why the call to "this.slideNext() " in the code below does not work. Apparently "this.slideNext() " is not a function? Code: function ScoopAnimation(_path, _start, _end, _delay){ this.start = _start this.end = _end; this.delay = _delay; this.path = _path this.currentFrame = _start; this.slideNext() = function (){ this.currentFrame ++; console.log(' next this.currentFrame : ' +this.currentFrame ); } this.start= function () { console.log('next this.start() : ' +this.currentFrame ); //THE NEXT LINE CAUSES THE ERROR! this.slideNext() } this.start(); } I'm not really looking for someone to fix/answer this for me, but maybe give me a hit in the right direction. I need to fix this while loop to run correctly, but has errors in the code. This code is supposed to fill an array with numbers 1 through 100 and then print them. Here is the code: <script type="text/javascript"> /* <![CDATA[ */ var count = 0; var numbers = new Array(100); while (count < 100) { numbers[count] = count; ++count; } while (count < 100 ) { document.write(numbers[count]); ++count; } /* ]]> */ </script> What i am most confused about is this part of the code numbers[count] i don't understand what is going on there. Sorry i am very new to this. Any ideas would be appreciated thank you. Hey Guys, I was creating an image map with rollover images. I was just wondering if I could add a fade effect to the transition. The underarms is the only rollover that works at the moment. Please check the source code for the code because it's too long to post here. http://wedezign.com/chris/ So erm. Hello there. I fail at javascript, and yet, I'm trying it. Anyways, I'm working on this thing. It's an extension for google chrome very similar to firefox plugins and so on. I'm making an extension so that, when installed, it changes the look of facebook completely. I have successfully changed the colors. However, I am having some trouble getting my javascript to change images. If anybody out there has some insight on what I'm doing wrong, I am glad to accept any kind of help that anyone is willing to give me, lol. What I've done so far: I have to change the facebook logo (what I'm trying to do now) and then change the links, and very few more things, and I'm done. Problem: I can't figure out how to change the image. I can change the background color, as you saw earlier. I just need a code to change the image. The CSS behind it is: Code: #pageLogo a{background:#3b5998 url(/rsrc.php/z8S5R/hash/ez3x5cuc.png) no-repeat -21px 0;display:block;position:absolute;height:31px;left:-6px;width:103px;top:10px} and the HTML implementing it is: Code: <h1 id="pageLogo"><a href="http://www.facebook.com/?ref=logo" title="Home" accesskey="1"></a></h1> and my structure of javascript is: Code: for(i=0;i<=document.getElementsByTagName("div").length;i++) { if(document.getElementsByTagName("div")[i].id != null) { if((document.getElementsByTagName("div")[i].id=="blueBar")) { document.getElementsByTagName("div")[i].style.backgroundColor='#B22222'; } if(( document.getElementsByTagName("div")[i].id == "headNavOut")) { document.getElementsByTagName("div")[i].style.backgroundColor='#8B0000'; } } } }); I appreciate any help anyone's willing to give. I have a question about Javascript. Hello. I need help with JavaScript enabled. My job so that I can automatically send button to be pushed faster. I use google chrome. For example; Automatically have form filling add-ons. (Autofill), but only to fill the send button will not print. How can I do this automatically? Button codes; <input type='submit' name='post_shout' value='Shout' class='button' /> Google Chrome address bar: javascript: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx what I need to write here? Can I do it after 1-2 seconds and fill out? Many thanks in advance. (My English is poor) I am very new to this, so I appreciate everyone's help and patience I am displaying information on our company intranet. I want the user to be able to choice if they want to see the information sorted by person or by issue. Because of the way that this is setup, the info is not in a table and cannot be sorted. I want users to be able to view content either way, but with only one option being visible. This would require the OR operator combined with the toggle function (I assume), but I am pretty lost... This toggle below allows me to show/hide one on top of the other, but I want one to replace the other: <SCRIPT type=text/javascript> <!-- function toggle_visibility(id) { var e = document.getElementById(id); if(e.style.display == 'block') e.style.display = 'none'; else e.style.display = 'block'; } //--> </SCRIPT> <P><STRONG><FONT color=#00467f size=3>Primary Contacts</FONT></STRONG></P> <P><A onclick="toggle_visibility('issue');" href="#">Toggle Contacts by Issue</A></P> <P> </P> <DIV style="DISPLAY: none" id=issue>%%Pages.Body PageID="596"%%</DIV> <DIV style="DISPLAY: block" id=pers>%%Pages.Body PageID="595"%%</DIV> Again, I really appreciate the help I was going through an article on JavaScript objects on "http://www.howtocreate.co.uk/tutorials/javascript/javascriptobject" and there I read Quote: Intrinsic objects - variable types with constructors. * Array * Boolean * Date * Function * Image * Number * Object * Option * Regular Expression * String does it mean that, whenever I want to use any of these objects, I have to create it using new and only then I can use its properties or methods ? 1) There are other objects like document, history, location, navigator, parent and screen. If objects which need to be created using constructor are called intrinsic objects , then what are other objects which can be used without constructor are called as ? Array, Boolean, Image, Date etc all start with capital letter. While document, history, navigator etc start with lower case letter. Why is that ? Is there any difference between objects that start with upper case and those start with lower case ? Are they known by different names ? Thanks Hello to everyone, I got a bit of a situation here, I wrote this code that basicaly what it does is, gets code from input field, sends it to php file get the results back and also calls the second php page to chage the prices but kill me I cant figure out what I did wrong Can anyone help? Here is the code: <div style = "position: relative; width: 100%; height: 100%;" id = "idCouponRequest"> <table width="100%" border="0" cellspacing="4" cellpadding="4" id = "tblCoupon"> <tr> <td class="detHeadTxt" align="right" valign="middle">Enter Your Coupon:</td> <td width="165" align="center" valign="middle"><input id = "edtCoupon" type="text" name="coupon" size="32" maxlength="15"></td> <td width="175" align="right" valign="middle"><INPUT type="image" name="coupon" src="images/redeem.gif" class = "mnCurs" border="0" onclick = "javascriptostCheckout();"></td> </tr> </table> </div> <script language = "javascript"> var couponCode; function postCheckout() { getContent('includes/checkout/processCoupon.php', 'coupon_code=' + document.getElementById('edtCoupon').value, function () { couponCode = document.getElementById('edtCoupon').value; var win = document.getElementById('idCouponRequest'); win.innerHTML = '<table border = 0 width = 100% height = 100%><tr><td align = center valign = center class = \"detCartHead\">Processing Coupon...</td></tr><tr><td align = center valign = center><img src="images/rating_loading.gif" alt="loading" /></td></tr></table>'; }, function () { if (xmlHttp.readyState != 4) return; var res = xmlHttp.responseText; var win = document.getElementById('idCouponRequest'); win.innerHTML = res; refreshOrderSumm(); }); } function refreshOrderSumm() { getContent('includes/checkout/processOrderSumm.php', 'coupon_code=' + couponCode, function () { var win = document.getElementById('divSummLoading'); win.style.display = ''; }, function () { if (xmlHttp.readyState != 4) return; var res = xmlHttp.responseText; var win = document.getElementById('divSummLoading'); win.style.display = 'none'; var win = document.getElementById('divCouponSumm'); win.innerHTML = res; }); } </script> I have a general javascript question. It may apply in this forum but maybe in the asp forum. I have a java applet on a site that I am building. If someone visiting the site doesn't have their javascript turned on, and chooses not to, is there some line of code that I can use that will detect that and replace the applet for an image I create? The site is developed in asp, but being that it is a javascript question, I thought it may apply here. Gary Hi all, I created a program for my company that allows employees to log in, and make their annual leave selections. It was made in Flash Builder with AS3. It contains a datagrid with 7 available leave slots for each day of the year. Employees click on an available slot and their name in inserted. We go through this process 4 times, with each employee selecting 5 days per round until they have selected up to 20 days of annual leave. We use company seniority to rank the order in which the employees pick. I hope I've explained that clearly enough to have someone help me with my question Since I want to move from Flash, I would like to use Javascript, Jquery and HTML5 to completely redo our website so it can be used on phones, tablets, etc. I have built a calendar and can cycle through the months (i'd eventually like to get a year view), but I'm having issues with a couple of items I had built into the flash version. First of all, I want to be able to show each employees work schedule on the calendar. They all work rotating shifts of 5 on 4 off. In AS3 i've taken their rotation, paired it with a start date for that rotation and was able to indicate in the datagrid "WORKING" on their days of work. This enables them to pick leave on their correct working days. In Jquery, I'd like to color the calendar on the dates that they are scheduled to work. IS that possible? Secondly, they pick 5 days of leave at a time. I'd like to display a token of some sort on the page that contains their name. They could then drag the token to a day that they would like to have off. Once they click submit, the selections are submitted to the MySQL database I have set up. How can I create these tokens based on the user's login name. Sorry for the noob questions. I'm just trying to get my head around the nuances of Javascript and jQuery Thanks for any help!! |