JavaScript - Quadtree Url Generator For Gigapan Images
Below is a function to download a set of images from a website based on the width, height and levels of the image which is obtained from the following config file:
http://api.gigapan.org/beta/gigapans/10826.json If I use 10826 as the gigapanId, I get a width of 50944, height of 14269 and levels 9 for the below variables. What I am trying to do is rather then use this as a function, I want to convert this into a basic script which just outputs to the screen all the possible urls that images would be at based on the width, height and levels of the source gigapanId. Any thoughts on how I should do this? Should I be using javascript to do this or would another language be better for this? Thank you so much for any help! Chris Code: GigapanTileSource.prototype = new Seadragon.TileSource(); GigapanTileSource.prototype.constructor = GigapanTileSource; function GigapanTileSource(gigapanId, width, height) { Seadragon.TileSource.call(this, width, height, 256, 0, 8); this.gigapanId = gigapanId; //alert('gigapanid:'+gigapanId); this.getTileUrl = function(level, x, y) { if (level >= 8) { level = level - 8; } var url = 'http://share.gigapan.org/gigapans0/' + this.gigapanId + '/tiles'; var GC_TILE = ["0", "1", "2", "3"]; var name = "r"; var bit = 1 << level >> 1; while (bit) { name = name + GC_TILE[(x & bit ? (1) : (0)) + (y & bit ? (2) : (0))]; bit = bit >> 1; } var i = 0; while (i < name.length - 3) { url = url + ("/" + name.substr(i, 3)); i = i + 3; } if (gigapan[name] == null & gigapan[name] !== null) { //alert('no translation'); return (url + "/" + name + '.jpg'); }else{ //alert("gigapan['id']"+gigapan['id']+" gigapan["+name+"]:"+gigapan[name]); return ("http://farm4.static.flickr.com/" + gigapan[name] + ".jpg"); } }; Similar TutorialsHi could someone please help?... I am a total beginner to javascript... but does anyone know of a code, including links to an image folder, for displaying 6 fullscreen images in random order without repeat for a given user? I've seen specific examples using shuffle on the site, but could anyone write a general code for any given images? Many thanks in advance Hello. I'm new here and learning JavaScript. Could you help me to write very simple script to auto generate user name ? From any letters. Min 6 - Max 10. Like: "jgFJFJ" "KGHGyvk" etc. Please help. Hey I'm somewhat new to the javascript world because 95% of my website is HTML so, if you will, I need help writing the javascript for a Random Question Generator...basicly all I have is Code: <script type="text/javascript"> var Q = new Array() Q[1] = "What is your favorite color?"; Q[2] = "What is your favorite animal?"; Q[3] = "What is your favorite place?"; </script> In the real one, there will be about 20 questions and I will need it to choose a quetion randomly out of the 20. As I said i am a beginer so as simple as possible would be great. Thank You for your help in advance Hello, I want to make myself a tool where if I paste in multiple lines of text cells (most likely from Excel, but that shouldn't matter), it will generate the pre-file extension and the ending file extension and echo it back on the page (not saving or storing, just temporary). I have no trouble creating a form in javascript (or php) that could input the extension automatically for 1 item, but I was wondering if it's possible for a list of multiples within the same form box? For example, I want to copy and paste this set of assets from excel into my form box: asset1 asset2 asset3 asset4 asset5 asset6 asset7 Submit it and receive an echo on the page of this. The stuff in bold will always be the same, just wrapped around the asset i inputted into the form. /f1/blah/example/asset1.xml /f1/blah/example/asset2.xml /f1/blah/example/asset3.xml /f1/blah/example/asset4.xml /f1/blah/example/asset5.xml /f1/blah/example/asset6.xml /f1/blah/example/asset7.xml I was able to create the form for 1 item, but not multiple. I just started to learn... so please don't be mad or flame me!! I am just wondering how difficult it is to learn to make this. Thanks! I know i don't have any code but does anyone have ideas how to start one? Preferably not squares hexes as each piece.
Hi there... actually i am working on a project "random password generator". What basically is to be done in this project is to generate user password for the username randomly he has provided. Then, this password is to be stored in a text file in the following manner UserName Password ABCD JU12H6 Sdjksj HJudfdsfd Now my problem is that every time I just try to generate a new password, either a new file is made or the heading is rewritten again and again or if I just try to change the variables true and false, then the username and password headings are not printed. Please help. If someone knows how to do this using if-else method then please tell me, how it can be done? The code is attached. Code: <html> <HEAD> <SCRIPT LANGUAGE="JavaScript"> function GetSelectedItem() { chosen = ""; for (i = 0; i <3; i++) { if (document.myform.opt[i].checked) { chosen = document.myform.opt[i].value; } } if (chosen == "") { alert("Choose your password type") exit; } return chosen; } function getPassword(usnm,length,opti) { if(usnm=="") { alert("Enter user name"); exit; } var optsel=GetSelectedItem(); var num = "0123456789"; var alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; var alphanum = "0123456789abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; var pass = ""; if(length!=5 && length!=6 && length!=7 && length!=8 && length!=9 && length!=10) { alert("Enter password length between 5 and 10"); exit; } else { if (optsel==1) { for(x=0;x<length;x++) { i = Math.floor(Math.random() * 72); pass += alphanum.charAt(i); } } else if (optsel==2) { for(x=0;x<length;x++) { i = Math.floor(Math.random() * 10); pass += num.charAt(i); } } else if (optsel==3) { for(x=0;x<length;x++) { i = Math.floor(Math.random() * 52); pass += alpha.charAt(i); } } WriteToFile(usnm,pass); return pass; } } function WriteToFile(usnm,pass) { try { var fso1=new ActiveXObject("Scripting.FileSystemObject"); var pf1=fso1.OpenTextFile("Password.text",8); //if(pf=='false') //var fso=new ActiveXObject("Scripting.FileSystemObject"); //dspf=fso.OpenTextFile("Password.txt",8,true); //pf.WriteLine("Username\t\tPassword"); pf1.WriteLine(usnm+'\t\t'+pass); pf1.Close(); } catch(err) { var fso=new ActiveXObject("Scripting.FileSystemObject"); pf=fso.CreateTextFile("Password.txt",8,false); pf.WriteLine("Username\t\tPassword") pf.WriteLine(usnm+'\t\t\t'+pass); pf.Close(); } // fso= null; /* else { //var fso = new ActiveXObject("Scripting.FileSystemObject"); var s = fso.CreateTextFile("D:\\Password.txt", true); s.WriteLine('Username\t\tPassword'); //while(s.next()) s.WriteLine(usnm+'\t\t'+pass); s.Close(); }*/ /*var fso = new ActiveXObject("Scripting.FileSystemObject"); var s = fso.OpenTextFile("D:\\Password.txt",8, true); s.WriteLine('Username\t\tPassword'); //while(s.next()) s.WriteLine(usnm+'\t\t'+pass); s.Close();*/ } </script> </HEAD> <BODY> <center> <table width=80% border=0> <tr align=center> <td> <form name="myform"> <table border=0> <tr> <td> Enter Username: </td> <td> <input type=text name=userName value="" size=20> </td> </tr> <tr> <td> Chooose Password type:</td> <td> <input type="radio" name="opt" value="1" >Alphanumeric <input type="radio" name="opt" value="2">Numeric <input type="radio" name="opt" value="3">Alphabetic </td> </tr> <tr> <td> </tr> <tr> <td> Password length: </td> <td> <input type=text name=passwordLength value="" size=2> </td> </tr> </table> </td> </tr> <tr align=center> <td> New password: <input type=text name=password size=20> <br> <input type=button value="Generate password" onClick="document.myform.password.value = getPassword(document.myform.userName.value,document.myform.passwordLength.value, document.myform.opt.checked);"> </form> </td> </tr> </table> </center> </html> Hi. I have a problem with a random link generator within a DIV. When I try it on my desktop it works fine, but does nothing once I upload it to the website. I'm not sure how to explain what happens, but here is it, more or less: The website is this: http://torcacita.atspace.com Via an Ajax script, http://torcacita.atspace.com/menu.html is loaded into DIV "menu". Here's the script: <script type="text/javascript"> ajaxpage('menu.html', 'menu') //load "menu.html" into "menu" DIV </script> Well, there's another load of stuff inside the <head> tag. You may see it from the main page source code. Anyway, if you go to the menu.html, the link generator will work there as it is intended; however, if you try it from the main page, it won't do anything. But people are not suppossed to go to menu.html. They are suppossed to load it from the index.html (I mean, plain http://torcacita.atspace.com) So, here's the link generator code: --------------------------------- <script type="text/javascript"> function randomlinks(){ var myrandom=Math.round(Math.random()*9) var links=new Array() links[0]="http://www.javascriptkit.com" links[1]="http://www.dynamicdrive.com" links[2]="http://www.cssdrive.com" links[3]="http://www.codingforums.com" links[4]="http://www.news.com" links[5]="http://www.gamespot.com" links[6]="http://www.msnbc.com" links[7]="http://www.cnn.com" links[8]="http://news.bbc.co.uk" links[9]="http://www.news.com.au" window.location=links[myrandom] } </script> <form> <input type="button" value="Lo Que Sea" onClick="randomlinks()"> </form> --------------------------------- I believe this could be solved if I could target the generator to the whole window, 'cause maybe it's trying to open the new page inside the DIV. Well, I don't know... So, what do you think? Could somebody help me? Hi, my assignment is to create an online quiz with a random image generator. I have created my online quiz using 5 linking files and everything works great. My only problem is getting the images to show up on my quiz. All I get is the filename with a red X. Which the files do show up at random when I refresh, so I know that part is working. I just don't know what I am missing to get the actual picture to show up. Please take a look at my code below and see if I am missing anything. Please keep in mind this isn't the whole code as I have different linking files for this assignment. Thank you in advance. Code: <?xml version = "1.0" encoding = "utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!-- Assignment CH10 Solution --> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <title>Online Quiz</title> <script type = "text/JavaScript"> <!-- var rimg = 0; var pictures = [ "logo", "logo2", "logo3", "logo1", "cover" ]; function randpics(){ var myQuiz = document.getElementById( "myQuiz" ); rimg = Math.floor( Math.random() * 5 ); myQuiz.logo.src = pictures[rimg]+'.gif'; myQuiz.logo.alt = rimg + ' : ' +pictures[rimg]; } function checkAnswers() { var myQuiz = document.getElementById( "myQuiz" ); if ( myQuiz.elements [ 0 ].checked ) alert ( "Congratulations, your answer is correct" ); else // if the answer is incorrect alert ( "Your answer is incorrect. Please try again" ); } // end function checkAnswers --> </script> </head> <body onload="randpics()"> <form id = "myQuiz" onsubmit = "return checkAnswers()" action = ""> <img name="logo" src="logo.gif" alt="javascript logo"/> <br /> <p>Which company first implemented the JavaScipt language?<br /> <input type = "radio" name = "radiobutton" value = "logo" /> <label>Netscape Communications Corp.</label> <input type = "radio" name = "radiobutton" value = "logo2" /> <label>Microsoft Corp.</label> <input type = "radio" name = "radiobutton" value = "logo3" /> <label>Sun Microsystems Corp.</label> <input type = "radio" name = "radiobutton" value = "logo1" /> <label>Consortium of all the companies</label><br /> <input type = "submit" name = "submit" value = "Submit" /> <input type = "reset" name = "reset" value = "Reset" /> </p> </form> <p> Click here to continue <a href = "page1.html" target="_self">Next Question</a> </p> </body> </html> I have a piece of code that randomly picks a line from a preset list and displays it whenever the page is loaded. I'm using it to generate random quotes on my pages. At the moment, there seems to be a good chance that when the page loads no quote appears at all, just a blank space. Anyone know why this could be happening? the code I am using is: Code: <script type="text/javascript"> q0= "<img src=\"images/quotes/01.png\" />"; q1= "<img src=\"images/quotes/02.png\" />"; q2= "<img src=\"images/quotes/03.png\" />"; q3= "<img src=\"images/quotes/04.png\" />"; q4= "<img src=\"images/quotes/05.png\" />"; q5= "<img src=\"images/quotes/06.png\" />"; q6= "<img src=\"images/quotes/07.png\" />"; q7= "<img src=\"images/quotes/08.png\" />"; q8= "<img src=\"images/quotes/09.png\" />"; q9= "<img src=\"images/quotes/10.png\" />"; q10= "<img src=\"images/quotes/11.png\" />"; q11= "<img src=\"images/quotes/12.png\" />"; var ran_unrounded=Math.random()*11; var ran_number=Math.round(ran_unrounded); document.write(eval("q"+ran_number)); </script> Hey guys. It's been a while since I was last here but I'm having a few problems. I'm building a random word generator form for a friend but my knowledge of JS is limited. I have found a script to randomly generate a word at the click of a button. Quote: <!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>Untitled Document</title> <SCRIPT LANGUAGE="JavaScript"> <!-- // Use the following variable to specify // the number of random words var NumberOfWords = 28 var words = new BuildArray(NumberOfWords) // Use the following variables to // define your random words: words[1] = "czarevitch" words[2] = "brightwork" words[3] = "verkrampte" words[4] = "protectrix" words[5] = "nudibranch" words[6] = "grandchild" words[7] = "newfangled" words[8] = "flugelhorn" words[9] = "mythologer" words[10] = "pluperfect" words[11] = "jellygraph" words[12] = "quickthorn" words[13] = "rottweiler" words[14] = "technician" words[15] = "cowpuncher" words[16] = "middlebrow" words[17] = "jackhammer" words[18] = "triphthong" words[19] = "wunderkind" words[20] = "dazzlement" words[21] = "jabberwock" words[22] = "witchcraft" words[23] = "pawnbroker" words[24] = "thumbprint" words[25] = "motorcycle" words[26] = "cryptogram" words[27] = "torchlight" words[28] = "bankruptcy" function BuildArray(size){ this.length = size for (var i = 1; i <= size; i++){ this[i] = null} return this } function PickRandomWord(frm) { // Generate a random number between 1 and NumberOfWords var rnd = Math.ceil(Math.random() * NumberOfWords) // Display the word inside the text box frm.WordBox.value = words[rnd] } //--> </SCRIPT> </head> <body> <FORM NAME="WordForm"> <INPUT TYPE=TEXT SIZE=10 NAME="WordBox"><BR> <INPUT TYPE=BUTTON VALUE="Click Here to Get a Random Word" onClick="PickRandomWord(document.WordForm);" > <input TYPE="reset" VALUE="CLEAR" onClick="clearForm(this.form)"> </FORM> </body> </html> This works without problems, however by friend wants to be able to fill multiple boxes with words from different lists by clicking only 1 button. The script above will allow me to do separate boxes with their own buttons. If anyone can help it would be greatly appreciated. Foster I am taking a Javascript class and the teacher assigned this: Quote: Write a script that uses a random number generation to create sentences and name it sentences.html. Use five arrays of strings called: uppercase article (uarticle), noun, verb, lowercase article (larticle), and preposition. You will need to use the correct case for the article arrays. Create a sentence by selecting a word at random from each array in the following order: uarticle, noun, verb, preposition, larticle, noun. You can find examples of generating random numbers in both Fig. 8.6 (dice-rolling) and Fig. 8.7 (random image) of Chapter 8. The arrays should be filled at minimum, as follows: the article array(s) should contain the articles: the, a, one, some and any. The noun array should contain the nouns: boy, girl, dog, town and car. The verb array should contain the verbs: drove, jumped, ran, walked, and skipped. The preposition array should contain the prepositions: to, from, over, under and on. If you would like to add more words, adjust the arrays appropriately. As each word is picked, concatenate it to the previous words in the sentence. The words should be separated by spaces. When the final sentence is output, it should start with a capital letter and end with a period. The program should generate 20 sentences and output them to the screen (document.write or document.writeln). You should use a for loop similarly to the one used in Fig. 8.6 in order to get it to print 20 times. I haven't gotten to the loop yet, I'm just working on the random sentence first. Here is what I have: Code: <script type="text/javascript"> <!-- uarticle = new Array("The", "A", "One", "Some", "Any"); noun = new Array("boy", "girl", "dog", "town", "car"); verb = new Array("drove", "jumped", "ran", "walked", "skipped"); larticle = new Array("the", "a", "one", "some", "any"); preposition = new Array("to", "from", "over", "under", "on"); var rand1 = [Math.floor ( Math.random() * uarticle.length )]; var rand2 = [Math.floor ( Math.random() * noun.length )]; var rand3 = [Math.floor ( Math.random() * verb.length )]; var rand4 = [Math.floor ( Math.random() * larticle.length )]; var rand5 = [Math.floor ( Math.random() * preposition.length )]; document.write(uarticle[rand2] + " " + noun[rand2] + " " + verb[rand3] + " " + preposition[rand1] + " " + larticle[rand4] + " " + noun[rand2] + "."); --> </script> Am I on the right track? How would I loop the sentences using a for statement? Trying to develop a small app for my site. What is the code to generate a random # of lines (1 min - 5 max) and a random phrase for each line sourced from a multidimensional array? These also need to be unduplicated (so I won't have quote 1 be on lines 1 and 4). How do I prevent random duplication with the generated lines of text? Thanks!
Hi all again, Firstly thanks to Philip M for getting me this far but i still have a few quirks that i'd like to get around. Its a price generator with 3 options. User selects an option from a drop down, inputs "number of words" and hey-presto the price appears. That works superbly well but what would be really cool is if after someone gets a price they then would like to select a different option in order to see a new price. At the moment it means selecting another option and re-entering the number of words and then clicking in the price box to get the new result. Is there anyway to make that price change automatically (as if by magic even) if either the "option" or "number of words" is changed I have a sneaky suspicion that Philip M will come to the rescue again but should anyone else have a view that would be great also. Thanks as always in advance, Phil Code: <head> <!--quote generator --> <script type="text/javascript"> function update(){ var price = document.getElementById("Package").value; var words = document.getElementById("words").value; var wordsOver2000 = words-2000; if (wordsOver2000 <0) {wordsOver2000 = 0} words = words - wordsOver2000; var Tprice = ((price * words) + (price * .80 * wordsOver2000)).toFixed(2) ;document.getElementById("Totprice").value = Tprice; document.getElementById("Totprice2").innerHTML = "Your Quote Total Is: MYR" + Tprice } </script> <!--end quote generator --> </head> Code: <body> <!--quote generator --> <div align="center" class="generator"> PACKAGE - <select name="Package" id = "Package"> <option value="0.027">Economy</option> <option value="0.038">Standard</option> <option value="0.049">Express</option> </select> No. of Words - <input type="text" id="words" onchange="update()" value="" /> ---> MYR <input type = "text" id = "Totprice" value="...then click here" /><br /> <br /><strong>(NB - To see a quote for a different package, please select package and re-enter the number of words)</strong> </div> <!--end quote generator --> </body> Ok, so I decided to make an Experience Generator for my site. I started simple by making one that uses a prompt. First it prompts for your level, then it multiplies it by using a random number function. This code below. Code: <html> <head> <title>Experience Generator</title> <script type="text/javascript"> var A= Math.round(Math.random()*100); var B= prompt('Place your Level Here'); function Expearned() { document.write(Exp=B*A); document.write(" Experience Points Earned"); } </script> </head> <body> <a href="javascript:Expearned()">Experience Calculator</a><br /> </body> </html> Then, I thought... I don't like using prompts. So, how about using text inputs and buttons instead. I then created this code. Code: <html> <head> <title>Experience Generator</title> <script type="text/javascript"> var A= Math.round(Math.random()*100); var B= input(); function Expearned() { document.write(Exp=B*A); document.write(" Experience Points Earned"); } </script> </head> <body> <FORM ACTION="#" NAME=LeveltoExp></FORM> Enter Level <INPUT TYPE=TEXT NAME="Enter Level" SIZE=3> <BR><BR> <INPUT TYPE=BUTTON VALUE="Earn Experience" ONCLICK=" Expearned() + 'is ' + ' Experienced Earned'"> <BR><BR> </FORM> </body> </html> BUT this code pulls up and error at the line of var B.. What I am trying to do is pass the form to the var B and then goes on from there to do the Experience Generator. Can anyone Help me???? Question about random link generator http://www.javascriptkit.com/script/cut1.shtml I want to use this script to hold a hundred odd links and show 8 random urls at a time in a list separated by a couple of line breaks. (Instead of just one). Could someone pls alter the code to allow me to do this please ... I also hope to keep the js file off the main html page. (naming the file list.js) Could someone also indicate how I do this. Hopefully these questions are easy if you know how etc. So far i havent been able to do it... Would be good if i could add a line to prevent duplicate randomly drawn links appearing in the list of eight.... thanks very much if you able to indicate it..... I have been asked by a friend to create a math sheet generator for their child, however i don't have a clue where to start with javascript. Similar to this.. http://cemc2.math.uwaterloo.ca/mathf...sheetgen.shtml It doesn't need to be advanced as that as all i'm looking for is how to create the sums. If someone could help either by informing me where to start or even an online tutorial i would be extremely greatful! Many thanks, James Hey guys, I scripted a javascript guessing game and I am not sure how I can configure the random number generator to only generate one number and then stop. Here is my code: Code: <html> <head> <title>Guess it up! </title> </head> <body> <center> <BODY onLoad="GenerateNumber()"> <b><font size="5" ><u><b>Guess it up!<br></b></u> <br > <font size="3"> This is out of: <br> <input id="DefaultNumber" name="DefaultNumber" type="text" size=3><br> Type in your guess: <br> <input id="HisGuess" name="HisGuess" type="text" size=3> <p> <input name="StartButton" type="button" value="Guess" onclick="StartGame()"> </p> <script type="text/javascript"> function GenerateNumber() { var TheRightGuess = Math.round(Math.random() * (document.getElementById("DefaultNumber").value))+1; //Makes the randomly generated right guess. The "+1" makes it 1-5 instead of 0-4. } function StartGame() { var TheRightGuess = Math.round(Math.random() * (document.getElementById("DefaultNumber").value))+1; //Makes the randomly generated right guess. The "+1" makes it 1-5 instead of 0-4. var HisGuess = parseInt(document.getElementById("HisGuess").value);//his guess var DefaultNumber = parseInt(document.getElementById("DefaultNumber").value);//number that they want to guess in. //NUMERIC TEST STARTS HERE if (HisGuess != parseInt(HisGuess) || (DefaultNumber != parseInt(DefaultNumber))) { alert("Please enter numbers only.") } //NUMERIC TEST ENDS HERE if (DefaultNumber <= 0) //Fixed bug:Guessing in zero. { alert("You can't guess in zero!?") } else if (DefaultNumber === 1 && HisGuess === 1 || TheRightGuess == HisGuess && DefaultNumber != 1)//testing if they guessed in 1 and guessed 1. { alert("You got the number!") } else if (HisGuess > DefaultNumber)//if guess is higher then what they guess in. { alert("You can only guess below " + DefaultNumber + ".") } else if (HisGuess != TheRightGuess && HisGuess <= DefaultNumber && DefaultNumber != 1 || HisGuess == 0)//fixed bug: you can't guess 0. { alert("Guess again!") } } </script> </body> </html> Thanks, Fizz I developed this under Safari on my mac. I have only been scripting for about 1.5 days so I am not the best with debugging. What would cause this? Code: <html> <head> <script ="Javascript> // Setting vars var winW = screen.width var winH = screen.height; var winLW = (winW / 2) - 240 // Resizing and moving window self.resizeTo(480,640); self.moveTo(winLW,0); // Form reset function function reset() { document.shiftReport.reset(); } // Create report function function calculate() { // Name Vars var name = document.shiftReport.nameBox.value; var mname = document.shiftReport.ModNameBox.value; // Server Bar Vars var j = document.shiftReport.JurSel.value; var t = document.shiftReport.TriSel.value; var c = document.shiftReport.CreSel.value; var p = document.shiftReport.PreSel.value; // Form Text Vars var gnotes = document.shiftReport.GeneralNotes.value; var PWMS = document.shiftReport.PWMS.value; var SGB = document.shiftReport.SGB.value; var WPMW = document.shiftReport.WPMW.value; var CTaO = document.shiftReport.CTaO.value; // Time Vars var shifTime = document.shiftReport.TimSel.value; var this_weekday_name_array = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday") var this_month_name_array = new Array("January","February","March","April","May","June","July","August","September","October","November","December") var this_date_timestamp=new Date() var this_weekday = this_date_timestamp.getDay() var this_date = this_date_timestamp.getDate() var this_month = this_date_timestamp.getMonth() var this_year = this_date_timestamp.getYear() if (this_year < 1000) this_year+= 1900; if (this_year==101) this_year=2001; var this_date_string = this_weekday_name_array[this_weekday] + ", " + this_month_name_array[this_month] + " " + this_date + ", " + this_year //concat long date string if (shifTime=="Other") { var shifTime=prompt("Please enter shift time:","11:00AM - 1:00PM"); } // Creating Report var theReport = "<b>Name:</b> " + name + "<br><b>Mod Name:</b> " + mname + "<br><b>Date:</b> " + this_date_string + "<br><b>Time:</b> " + shifTime + "<br><br><b>General Comments:</b><br>** Jurassic " + j + " bars<br>** Triassic " + t + " bars<br>** Cretaceous " + c + " bars<br>** Prehistoric " + p + " bars<br><br>" + gnotes + "<br><br><b>Players Warnings/Mutes/Suspensions:</b><br>" + PWMS + "<br><br><b>Site Glitches/Bugs:</b><br>" + SGB + "<br><br><b>What Players/Mods Want:</b><br>" + WPMW + "<br><br><b>Current Trends and Observations:</b><br>" + CTaO var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,scrollbars=yes,width=480, height=640, left=400, top=0"; var docprint=window.open("","",disp_setting); docprint.document.open(); docprint.document.write('<html><head><title>Simple Shift Report</title>'); docprint.document.write('</head><body>'); docprint.document.write(theReport); docprint.document.write('</body></html>'); docprint.document.close(); docprint.focus(); } </script> <title>Simple Shift Report Generator</title> <style type="text/css"></style> </head> <body style="background-color:#e5e5e5; color: rgb(0, 0, 0);" alink="#ee0000" link="#0000ee" vlink="#551a8b"> <table bgcolor="003366"style="text-align: center; width: 100%;" border="0" cellpadding="2" cellspacing="0"> <tbody> <tr> <td></td> </tr> <tr> <td></td><td bgcolor="#1a4f85"><font color="#FFFFFF">Simple Shift Report Generator</font></td> <td width="30%"></td> <td width="20%" style="text-align: right;"><font color="#8099b3" size="1">aaron smithers</font></td> </tr> </tbody> <br> <form name="shiftReport"> <table bgcolor="#DCDCDC" bordercolor="#FFFFFF" style="text-align: right; width: 100%;" border="15" cellpadding="2" cellspacing="1"> <tr> <td bgcolor="#e5e5e5"width="25%">Name:</td> <td bgcolor="d9e7f8" width="75%"><input name="nameBox" size="58" value="" type="text"></td> </tr> <td bgcolor="#efefef"width="25%">Mod Name:</td> <td bgcolor="#ffffcc"width="75%"><input name="ModNameBox" size="58" value="" type="text"></td> </tr> <tr> <td bgcolor="#e5e5e5"width="25%">Shift:</td> <td bgcolor="d9e7f8" width="75%"> <select name="TimSel"style="width:100%"> <option>Select Time - PST</option> <option>4:30AM - 5:30AM</option> <option>5:30AM - 7:00AM</option> <option>7:00AM - 8:30AM</option> <option>8:30AM - 10:00AM</option> <option>10:00AM - 11:30AM</option> <option>11:30AM - 1:00PM</option> <option>1:00PM - 2:30PM</option> <option>2:30PM - 4:00PM</option> <option>4:00PM - 5:30PM</option> <option>5:30PM - 7:00PM</option> <option>7:00PM - 8:00PM</option> <option>7:00PM - 8:30PM</option> <option>8:30PM - 9:30PM</option> <option>Other</option> </select> </td> </tr> <tr> <td bgcolor="#efefef"width="25%">Jurassic:</td> <td bgcolor="#ffffcc"width="75%"> <select name="JurSel"style="width:100%"> <option></option> <option>0</option> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select> </td> </tr> <tr> <td bgcolor="#e5e5e5"width="25%">Triassic:</td> <td bgcolor="d9e7f8" width="75%"> <select name="TriSel"style="width:100%"> <option></option> <option>0</option> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select> </td> </tr> <tr> <td bgcolor="#efefef"width="25%">Cretaceous:</td> <td bgcolor="#ffffcc"width="75%"> <select name="CreSel"style="width:100%"> <option></option> <option>0</option> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select> </td> </tr> <tr> <td bgcolor="#e5e5e5"width="25%">Prehistoric:</td> <td bgcolor="d9e7f8" width="75%"> <select name="PreSel"style="width:100%"> <option></option> <option>0</option> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select> </td> </tr> <tr> <td bgcolor="#efefef"width="25%">General:</td> <td bgcolor="#ffffcc"width="75%"><textarea name="GeneralNotes" cols="42" rows="7" value=""></textarea></td </tr> <tr> <td bgcolor="#e5e5e5"width="25%">Warning:</td> <td bgcolor="#d9e7f8"width="100%"><textarea name="PWMS" cols="42" rows="5" value=""></textarea></td> </tr> <tr> <td bgcolor="#efefef"width="25%">Glitch:</td> <td bgcolor="#ffffcc"width="75%"><textarea name="SGB" cols="42" rows="5" value=""></textarea></td </tr> <tr> <td bgcolor="#e5e5e5"width="25%">Want:</td> <td bgcolor="#d9e7f8"width="100%"><textarea name="WPMW" cols="42" rows="5" value=""></textarea></td> </tr> <tr> <td bgcolor="#efefef"width="25%">Trends:</td> <td bgcolor="#ffffcc"width="75%"><textarea name="CTaO" cols="42" rows="5" value=""></textarea></td </tr> </tbody> </table> <table style="text-align: left; width:100%;" border="15"bordercolor="#e5e5e5" cellpadding="2" cellspacing="2"> <tbody> <tr> <td width="75%"bgcolor="#FFFFFF">|</td> <td width="25%"><Input Type = Button NAME = b1 width="48%" VALUE = "Create Report" onClick = calculate()><br> <input type="button" value=" Clear " onClick= reset()></td> </tr> </tbody> </table> </body> </html> I've looked everywhere for a random number generator which doesn't repeat. Tried loads and none have seemed to work. I'm making a quiz, 5 questions so far. This button, in html, generates the next random Q: Code: <input type="button" value="Next (random)" name="B0" onClick="rangen();generatequestions();qnum()"><br><br> Lower down in the javascript (in the body), here is the rangen() function: Code: function rangen(){ whichone=Math.floor(Math.random()*5) } But I need a random generator which fires them off only once. For reference, here is the next bit (not so important): Code: var whichone=1; var q=1; var tempmn=document.instantquiz.thequestion function generatequestions(){ if (q>0) q=q++ if (loop>0) loop=0 document.instantquiz.theresponse.selectedIndex=0 if (!document.instantquiz.cmode.checked||whichone>=total+1||whichone<=0) document.instantquiz.thesolution.value='' if (whichone>=total+1) tempmn.value="End of quiz" else{ tempmn.value=whichone+")"+question[whichone]+"\n\n"+"a)"+eval('choice'+whichone+'[1]')+"\n"+"b)"+eval('choice'+whichone+'[2]' )+"\n"+"c)"+eval('choice'+whichone+'[3]')+"\n"+"d)"+eval('choice'+whichone+'[4]') if (document.instantquiz.cmode.checked) document.instantquiz.thesolution.value=solution[whichone] } } Anyone have suggestions for a non-repeating random number gen which will work? Even the one now seems to have some slight error associated with it. The one's ive tried so far haven't worked.. Hi all. I hope that everyone is fine and doing well. This is something of an annual visit for me. You guys helped me enormously with the code below. It is a price quote generator that takes a number (entered by the client) and depending on the package selected, produces a price quote. As I said, it works really well, but it's time for me to expand my business overseas. At the moment, I display the price as a single currency, but I would like for clients to be able to select (maybe from a drop down list in the answer field) any one of 4 different currencies (i.e., GBP, USD, EURO, MYR). The different exchange rates don't need to be up to the minute accurate. I'm quite happy to go in to the code and update them weekly or as required. I have attempted to research different ways of doing this, but as my needs are quite unusual and my brain really can't wrap around the ins and outs of java script, i'm here again begging with my cap in hand for help. To see this code in action as it stands, please go to www.grammarproofing.com Code: <head> <!--quote generator --> <script type="text/javascript"> function update(){ var price = document.getElementById("Package").value; var words = document.getElementById("words").value; if (words != "") { words = parseInt(words); if (isNaN (words)) { alert ("Please enter the number of words in figures"); document.getElementById("words").value = ""; return false; } } var wordsOver2000 = words-2000; if (wordsOver2000 <0) {wordsOver2000 = 0} words = words - wordsOver2000; var Tprice = ((price * words) + (price * .95 * wordsOver2000)).toFixed(2) ;document.getElementById("Totprice").value = Tprice; document.getElementById("Totprice2").innerHTML = "Your Quote Total Is: MYR" + Tprice } </script> <!--end quote generator --> </head> Code: <body> <!--start quote generator --> <div class="quote" id="quote"> <select name="Package" id = "Package" onchange = "update()"> <option value="0.052">STUDENTS THE 11th HOUR PACKAGE</option> <option value="0.041">STUDENTS EXPRESS PACKAGE</option> <option value="0.035" selected="selected">STUDENTS WORK in PROGRESS PACKAGE</option> </select> x <input type="text" id="words" onchange="update()" value="" /> WORDS<br /> = MYR <input type = "text" id = "Totprice" readonly /> </div> <!--end quote generator --> </body> Thanks in advance for any help offered. Regards as always, Phil |