JavaScript - Multiple Passwords?
Ok, I have no idea how to really even explain what's been asked of me, but it's seems to me that this could be a bit beyond my knowledge.
We're creating an alternate reality game which starts with a series of questions that people can choose from two answers. The answers will determine which path the person will travel. They'll be given a password at the end of the series of questions. There are three possible paths, which means three possible passwords given. On the same page, beneath the questions would be a text box with a "submit" button. The password they are given would be typed in there, and then they'd proceed to the proper page. This keeps from people being able to "skip" the questions portion. What they'd proceed to next is a video which is currently being made for our event, which has hidden puzzles and clues in it to find the next password. Rinse and repeat... My problem? How the heck do I make that box and submit button and password all work together when I have more than one password? Even more so, how do I make the password/submit button direct someone to the correct URL (without revealing the URL, and also prevents anyone from copying the URL and sharing it to bypass the password request)? For example: Questions are complete and the password "invention" is given. The person types in the word invention and presses submit. It directs the to www.url.com/game1 automatically. While someone else will come in, answer the questions, and the password "intelligence" would be given. That person types in the word intelligence and presses submit into the same box, using the same button that the person who typed in the word invention typed in. But this person would instead be directed to www.url.com/game2 If either person shared the link they were directed to, then it'd prompt people to put in a password before letting them in. How in the darn world do I make this happen?? LOL! Thanks in advance for any time, advice, or tutorials provided! ---------------------------------------- Added later.... I might need to go ahead and ask this as well.. since it got me to thinking.. How would I go about hiding the URL as well. I'm only interested in doing it for the game side of the site to keep from people sharing that URL and stripping the "fun" away from the game. Hopefully it is something simple? I'm fairly new at coding. My knowledge is no where as vast as I see many others here are. So if you should decide to have the patience to assist me, please be specific in steps like you are describing this to your kid who has no idea what you're talking about. I hate to present it that way, but I don't want to annoy anyone by stating I don't understand. Similar TutorialsPls help me as to how to code for the password form in html and then make it to be recognized in a notepad. what i mean is... when logging in or when entering a password the html should look or match it in a notepad and see if its the correct one. and to at least allow people to register and save the passwords in that same notepad. Thanks in advance Hi all, I'm trying to match two passwords to one another. The user enters the password into two fields and onblur from the second field, the function runs. Here is my code: Code: function validatePassword(inputField, inputField2, helpText, helpMessage) { // First see if the input value contains data if (!validateNonEmpty(inputField, helpText)) return false; var inputField = document.getElementById('inputField').firstChild.nodeValue var inputField2 = document.getElementById ('inputField2').firstChild.nodeValue } if (inputField !== inputField2) { // The data is invalid, so set the help message and return false if (helpText != null) helpText.innerHTML = helpMessage; } else { // The data is OK, so clear the help message and return true if (helpText != null) helpText.innerHTML = ""; } }; Code: document.getElementById('password2').onblur = function() { validatePassword(this, document.getElementById('password'), document.getElementById('password2_help'), "<p>Passwords don't match</p>'"); }; I am passing a help text to a span element inside the form: Code: <div class="fieldset"> <label for="password2">Confirm:</label> <input type="password" id="password2" name="password2" /> <span id="password2_help" class="help"></span><br/> </div><!--fieldset--> What's going on here? As far as I can tell it this should be working. Thanks, Andrew Need to write a script that will ask for password and then give an alert with either successful login or unsuccessful login. It needs to use the while loop and I need for the script to accept four different passwords. I can script it for one password but can not figure out how to get it to work for other the passwords. Unfortunately I don't know computer programming and very little html and was allowed to sign up for a course that is too advanced for me and I can't drop it because I will lose my financial aid so with I am really struggling in this class and the assignments do not really go with the textbook and examples provided. Here is the code I have so far: <html> <body> <script type="text/javascript"> var password = new Array ("midland", "baycity", "saginaw", "delta"); var tries = 3; password = prompt("Enter password", ""); while (password != "midland" && tries > 0) { alert("Incorrect password - You have " + tries + " more tries"); password = prompt("Enter password", ""); tries--; } if (password == "midland") alert("Login Successful"); else alert ("Login Failed - Please Try Later"); </script> </body> Hi, I hope someone can help me. I'll be honest and say I don't know much about javascript, but am fairly comfortable in html. I am building a website that will have multiple image swaps on multiple pages. I am building this in wordpress, and I'm guessing that means my approach will be different than if I wasn't using wordpress. Here's how one page would work: There are 10 images shown. 1,2,3,4,5,6,7,8,9,10. When number 1 is clicked on, I want a new image - 1a. When 2 is clicked on, 2a. So there are 20 different images in all on a given page. Also, I want the user to be able to click on the image again to restore the original image. I would prefer onclick to onmouseover. There will be literally dozens of pages like this on the site, managed by wordpress, so hundreds of images to swap. Basically the first image is a question - the second image is the answer. Is this possible? FYI: THIS IS NOT HOMEWORK! Hi all, I am trying to make an all-in-one function that can use local storage and provide 4 functions: (1) read data (2) write data (3) erase specific data (4) erase all data Here's the code block I have (with alerts in place of the local storage code for debugging): Code: var storage = function (name, value) { if (name) { if (value === null) { return alert('erase'); } else { if (value != null) { return alert('write'); } else { return alert('read'); } } } else { return alert('nuke'); } }; I want to use it like this: storage(); - erases ('nukes') everything storage('abc'); - reads data stored as 'abc' storage('abc', 'newvalue'); - stores 'newvalue' as 'abc' storage('abc', null); - erases data stored as 'abc' only It seems to work, but I have a funny feeling about trusting the difference between "==" and "===" to make it work. Am I wrong? Is there a real difference between == and === and am I doing this correctly? Thanks! -- Roger Hi all - I'm having difficulty with the processing of 3 forms on my web page. We'll call my 3 forms A, B, and C. By default my page shows form A. The other 2 forms I have hidden via display:none My issue is when I have form B or C showing. Once I hit submit, say within form B for example, I'd like this form to remain for future entries/submital of data. However, instead what happens is form A appears. How do I get form B to remain, allowing for a user to submit multiple entries of data without going back to form A? Here's my code for form 'B' <div id="branches_info" style=" <?php echo $display_branches; ?> "> form method="post" action="annual_report_main.php" onsubmit="return validateBranches(this);"> <fieldset> <p><strong>Branch Location</strong></p><br /> <label for="branch_address" class="long">Street Address:</label> <input maxlength="50" type="text" name="branch_address" id="branch_address" value="<?php echo htmlentities($_POST['branch_address']);?>" /><br /> <div class="cleaner"></div> <label for="branch_city" class="long">City:</label> <input maxlength="20" type="text" name="branch_city" id="branch_city" value="<?php echo htmlentities($_POST['branch_city']);?>" /><br /> <div class="cleaner"></div> <label for="branch_state" class="long">State:</label> <input maxlength="2" type="text" name="branch_state" id="branch_state" value="<?php echo htmlentities($_POST['branch_state']);?>" /><br /> <div class="cleaner"></div> <label for="branch_zip" class="long">Zip Code:</label> <input maxlength="10" type="text" name="branch_zip" id="branch_zip" value="<?php echo htmlentities($_POST['branch_zip']);?>" /><br /> <div class="cleaner"></div> <div class="content_onecolumn"> <input type="submit" name="Branches" value="Submit to Database" class="inputSubmit" /> </div> <div class="content_onecolumn"> <input type="button" name="Finished" value="Finished" class="inputSubmit" onclick="window.open('https://www.dca.ca.gov/webapps/bppe/thankyou.php');return false" /> </div> </fieldset> </form> </div> plz i want to know how to make the effects that exists on this link in the upper part : http://www.masrawy.com/new/ 1-) changing color when pressing on the color 2-) changing font (+) to increase it (-) to decrease it (N) to set it to the normal style 3-) decrease and increase the width of the page (from كبر حجم الصفحة or صغر حجم الصفحة ) can anyone help me in doing this task????? Im having problems with this code working as it should. the top banner is supposed to cycle the second banner is supposed to be random the 3rd is a slide show that is supposed to work in order Everything works in random order. Any help would be appreciated. Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>HTML and JavaScript</title> <script type="text/javascript"> var imgArray=new Array(4); imgArray[0]= new Image; imgArray[0].src="lions3.gif"; imgArray[1]= new Image; imgArray[1].src="tigers3.gif"; imgArray[2]= new Image; imgArray[2].src="bears3.gif"; imgArray[3]= new Image; imgArray[3].src="ohmy3.gif"; var index=0 function startup() { cycle(); select(); return } </script> <script type="text/javascript"> function cycle() { document.banner.src= imgArray[index].src; index++; if (index==4) { index=0; } setTimeout("cycle()",1000); return; } </script> <script type="text/javascript"> function select() { index=Math.floor(Math.random()*4); document.banner1.src=imgArray[index].src; setTimeout("select()",2000); return; } </script> <script type="text/javascript"> function doBack() { if (index>0) { index--; document.slideshow.src=imgArray[index].src; } return; } function doNext() { if (index<3) { index++; document.slideshow.src=imgArray[index].src; } return; } </script> </head> <body onload="startup()";> <center><img name="banner" src="lions3.gif" id="banner"> <div align="center"><img name="banner1" src="tigers3.gif" id="banner1"></div> </center> <div align="center"> <h2>My JavaScript Slideshow</h2> <p><img name="slideshow" src="lions3.gif"></p> <p><a href="javascript:doBack()">Back</a> * * * * <a href="javascript:doNext()">Next</a></p> </div> </body> </html> I have what would seem like an easy task, but is not working out that way. I have a basic html form with multiple user input boxes. Upon the submit button being clicked it validates the input with javascript and then emails the information with the forms mailto. What I need it to do, is email everything but the information in one textbox to a group of recipients, and the email all of the items to a different recipient. This need to be done to prevent certain induviduals from seeing certain items filled out on the form. I know this can easily be done in asp, php, or a server-side client of the sort, but we do not have access to any resources like this in this area of the company. I'm open for any suggestions you may have. Thanks ahead of time. Hi, I am new to Javascript, but am trying to work with a bit of script I found online to create a crossfade slideshow for my page. The problem I am having is that I want to have several slideshows on my page. On it's own, a single slideshow works fine but when I add a second (and do my best to hack the code with my limited knowledge) only one slideshow will work, or sometimes neither. I found the article from this site that explained about event conflict, but the example used looked quite a bit different to mine. Here is the js file I started with Code: window.addEventListener?window.addEventListener('load',so_init,false):window.attachEvent('onload',so_init); var d=document, imgs = new Array(), zInterval = null, current=0, pause=false; function so_init() { if(!d.getElementById || !d.createElement)return; css = d.createElement('link'); css.setAttribute('href','slideshow2.css'); css.setAttribute('rel','stylesheet'); css.setAttribute('type','text/css'); d.getElementsByTagName('head')[0].appendChild(css); imgs = d.getElementById('rotator').getElementsByTagName('img'); for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0; imgs[0].style.display = 'block'; imgs[0].xOpacity = .99; setTimeout(so_xfade,3000); } function so_xfade() { cOpacity = imgs[current].xOpacity; nIndex = imgs[current+1]?current+1:0; nOpacity = imgs[nIndex].xOpacity; cOpacity-=.05; nOpacity+=.05; imgs[nIndex].style.display = 'block'; imgs[current].xOpacity = cOpacity; imgs[nIndex].xOpacity = nOpacity; setOpacity(imgs[current]); setOpacity(imgs[nIndex]); if(cOpacity<=0) { imgs[current].style.display = 'none'; current = nIndex; setTimeout(so_xfade,3000); } else { setTimeout(so_xfade,50); } 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) + ')'; } } This uses a couple of CSS files and then you just add a div=rotator on the html to add the object and then the images and links within that div. If anyone can help, or perhaps give me a better solution, I'd be most grateful. Thanks here is my issue... i have an object and i need to call two functions. i need the onclick="something" to call a server side function and then i need another onclick="something" to call a javascript funtion... the problem is you can only have one "onclick" (similar to having one "class")... how can I set up an onclick that will call both my serverside function and my javascript function... I realize this is not specifically serverside section of forum, so pretend I am asking how to call two separate javascript functions with different names the item in question is here Code: <asp:Button ID="btn_gen1" runat="server" Text="InterventionCentral" class="show" onclick="btn_gen1_Click" onclick="autohide" onmouseover="details_visible(1)" onmouseout="details_hidden(1)" /> just showing this to clarify that javascript does work with the asp and my mouse functions are working fine... my asp onclick works as well.. i can remove the asp and leave the js and it will work, but then all the stuff i do server side for the onclick goes away is this able to be done? this is for dev testing and i will eventually run into the same problem of needing to call two separate javascipt functions via onmouseover and also onmouseout Hi, been using javascript for a while now, and wondering how else this could be coded to be more effective and to 'work'. The idea is that the user gets prompted, 'what is your birthday?' the user would put in 0121 or whatever their birthday is, as 01 = month and 21 = day. I'm sure you'll understand what I mean.... Code: <DOCTYPE html> <html> <script> var userAnswer = prompt("When is your birthday? Example: Jan 21st = 0121") </script> <head> </head> <body> <script> if(userAnswer >= 0101){ alert('You are Capricorn!') }; if(userAnswer >= 0120){ alert('You are Aquarius!') }; if(userAnswer >= 0219){ alert('You are Pisces!') }; if(userAnswer >= 0321){ alert('You are Aries') }; if(userAnswer >= 0420){ alert('You are Taurus') }; if(userAnswer >= 0521){ alert('You are Gemini!') }; if(userAnswer >= 0621){ alert('You are Cancer!') }; if(userAnswer >= 0723){ alert('You are Leo!') }; if(userAnswer >= 0823){ alert('You are Virgo!') }; if(userAnswer >= 0923){ alert('You are Libra!') }; if(userAnswer >= 1023){ alert('You are Scorpio!') }; if(userAnswer >= 1122){ alert('You are Sagittarius!') }; if(userAnswer >= 1222){ alert('You are Capricorn!') }; </script> </body> </html> Reply With Quote 01-18-2015, 10:01 AM #2 Mitchellwood101 View Profile View Forum Posts New to the CF scene Join Date Nov 2014 Posts 7 Thanks 0 Thanked 0 Times in 0 Posts And then it will alert the user of their star sign****** Reply With Quote 01-18-2015, 05:47 PM #3 Philip M View Profile View Forum Posts Supreme Master coder! Join Date Jun 2002 Location London, England Posts 18,371 Thanks 204 Thanked 2,573 Times in 2,551 Posts If you have been using Javascript for a while now, you should be aware that prompts and alerts are long obsolete, and I would advise that you should not be wasting your time learning this stuff. Use DOM methods to obtain input from and display messages to your users. Be aware that a value starting with 0 is a string, not a number, and so must be in quotes - that is why your code does not work. In any case you need rigorous checking to ensure that the birthday entered in this form is valid, e.g. not 56th Febtember or "Mickey Mouse". You would do best to obtain the input from select lists for month and day, expressed as numbers. A tiny bit more sophistication would allow the user to select a month by name, where the text of the option is the month name, and the value of that option the month number. Code: <select id = "monthlist" onchange = "getSignFunction()"> <option value = "0"> Choose your birth month</option> <option value = 1>January</option> <option value = 2>February</option> ... and so on </select> Then you want something like this:- Code: function getSignFunction()"{ var sign = ""; var month = document.getElementById("monthlist").value; var date = document.getElementById("datelist").value; if (month == 0) {return} // invalid choice if (month == 1 && date >=20 || month == 2 && date <=18) {sign = "Aquarius";} if (month == 2 && date >=19 || month == 3 && date <=20) {sign = "Pisces";} if (month == 3 && date >=21 || month == 4 && date <=19) {sign = "Aries";} if (month == 4 && date >=20 || month == 5 && date <=20) {sign = "Taurus";} if (month == 5 && date >=21 || month == 6 && date <=21) {sign = "Gemini";} if (month == 6 && date >=22 || month == 7 && date <=22) {sign = "Cancer";} if (month == 7 && date >=23 || month == 8 && date <=22) {sign = "Leo";} if (month == 8 && date >=23 || month == 9 && date <=22) {sign = "Virgo";} if (month == 9 && date >=23 || month == 10 && date <=22) {sign = "Libra";} if (month == 10 && date >=23 || month == 11 && date <=21) {sign = "Scorpio";} if (month == 11 && date >=22 || month == 12 && date <=21) {sign = "Sagittarius";} if (month == 12 && date >=22 || month == 1 && date <=19) {sign = "Capricorn";} alert (sign); // alert used here just for testing purposes. Crate as <span> and then use document.getElementById("spanid").innerHTML = sign to display the result to the user. } All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit. Hi folks. I am new to javascript so please go easy on me if this is a silly request Basically I have a table generated by a php script with a dynamic number of rows and columns. Here is a sample of the output from this script: Code: <tr> <td style='width:60px'><a href='index.php?inc_id=30' onclick='return confirmDelete(this)'>Remove</a></td> <td style='text-align:center'>test</td> <td ><input type='text' name='0inccol0' value='$432.00' style='text-align:center; background-color:#cccccc'/></td> <td ><input type='text' name='0inccol1' value='$432.00' style='text-align:center; background-color:#cccccc'/></td> <td ><input type='text' name='0inccol2' value='$432.00' style='text-align:center; background-color:#cccccc'/></td> <td ><input type='text' name='0inccol3' value='$432.00' style='text-align:center; background-color:#cccccc'/></td> <td ><input type='text' name='0inccol4' value='$432.00' style='text-align:center; background-color:#cccccc'/></td> <td ><input type='text' name='0inccol5' value='$432.00' style='text-align:center; background-color:#cccccc'/></td> <td ><input type='text' name='0inccol6' value='$432.00' style='text-align:center; background-color:#cccccc'/></td> <td ><input type='text' name='0inccol7' value='$432.00' style='text-align:center; background-color:#cccccc'/></td> </tr> <tr> <td style='width:60px'><a href='index.php?inc_id=31' onclick='return confirmDelete(this)'>Remove</a></td> <td style='text-align:center'>test2</td> <td ><input type='text' name='1inccol0' value='$213.00' style='text-align:center; background-color:#cccccc'/></td> <td ><input type='text' name='1inccol1' value='$213.00' style='text-align:center; background-color:#cccccc'/></td> <td ><input type='text' name='1inccol2' value='$213.00' style='text-align:center; background-color:#cccccc'/></td> <td ><input type='text' name='1inccol3' value='$213.00' style='text-align:center; background-color:#cccccc'/></td> <td ><input type='text' name='1inccol4' value='$213.00' style='text-align:center; background-color:#cccccc'/></td> <td ><input type='text' name='1inccol5' value='$213.00' style='text-align:center; background-color:#cccccc'/></td> <td ><input type='text' name='1inccol6' value='$213.00' style='text-align:center; background-color:#cccccc'/></td> <td ><input type='text' name='1inccol7' value='$213.00' style='text-align:center; background-color:#cccccc'/></td> </tr> <tr> <td style='width:60px'><a href='index.php?inc_id=32' onclick='return confirmDelete(this)'>Remove</a></td> <td style='text-align:center'>test3</td> <td ><input type='text' name='2inccol0' value='$65.00' style='text-align:center; background-color:#cccccc'/></td> <td ><input type='text' name='2inccol1' value='$65.00' style='text-align:center; background-color:#cccccc'/></td> <td ><input type='text' name='2inccol2' value='$65.00' style='text-align:center; background-color:#cccccc'/></td> <td ><input type='text' name='2inccol3' value='$65.00' style='text-align:center; background-color:#cccccc'/></td> <td ><input type='text' name='2inccol4' value='$65.00' style='text-align:center; background-color:#cccccc'/></td> <td ><input type='text' name='2inccol5' value='$65.00' style='text-align:center; background-color:#cccccc'/></td> <td ><input type='text' name='2inccol6' value='$65.00' style='text-align:center; background-color:#cccccc'/></td> <td ><input type='text' name='2inccol7' value='$65.00' style='text-align:center; background-color:#cccccc'/></td> </tr> What I want to do is create a row of 'totals' fields at the bottom of this table that will sum the fields in the column above. Looking at the naming convention above, the first number is the row, the number at the end is the column so I will want to sum all of the input values with a name ending in 0 in the first 'total' field, all the input values with names ending in 1 in the next and so on. The number of rows and columns is dynamic based on the users selections prior to buiding the table. The reason I am using input fields is that I would also like an event (onChange/onBlur?) that will update the totals fields if a user manually changes the value in one of the inputs. Any advice on this will be appreciated! I have a quick question with multiple array and random numbers. If i generate my random numbers in one array, how would i take a selection of those numbers and put them in another array? Ex: array 1: 25, 34, 38, 40, 22, 49 want to move numbers between 30 and 50 to another array. array 2: 34, 38, 40, 49 is it as simple as for loops and if statements setting the conditions? do i use a sorting method? (selection? bubble?) any help would be appreciated. Hello! I'm trying to make a website that from one link, opens multiple windows. It is for a design project (I'm still at uni). So far I have mustered just the one window. Here is the website: http://popmeup.org/ The idea is that you get bombarded with lots of nice quotes. I don't know my arse from my Javascript - but has anyone got any advice? I'm making a website, and my aim is to have a terminal like interface. I am encountering a problem with startup text. I cannot get it to work right with the following... function title() { document.getElementById("prompts").innerHTML = "OS v0.1"+ setTimeout("<br />> Loading...",2500)+ setTimeout("<br />> FATAL ERROR!",12500)+ setTimeout("<br />> Please enter command.",13500); } However I get undefined for the settimeouts. hi its me again. i was using the data that I pulled out from my db and then provide a push button weather to lock it or not but the problem is, the js code doesn't mouse over on the next button, here's the js code Code: var once = true; function asktolock(){ if(once){ document.getElementById('locker').value = "Lock Me ?"; } } function lockme(){ document.getElementById('locker').value = "Locked"; once = false; } and here's my html with php/js code PHP Code: <?php foreach($task->result() as $row): ?> <tr> <td><?php echo $row->title; ?></td> <td><input type="button" id="locker" value="unlocked" onmouseover="asktolock()" onclick="lockme()" /></td> <td><?php echo $row->assign_to; ?></td> </tr> <?php endforeach; ?> if I will put an "onmouseout" and feed it with a function like this Code: function passby(){ document.getElementById('locker').value = "unlock"; } the clicking function won't work anymore, what's the best thing to do? |