JavaScript - Help On Random No Pinpad
Dear all,
Appreciate your kind guidance and help in helping me to solve the following code. I wanted to generate a set of random number on the pinpad everytime the page is being loaded. (1-9 but the number can only appear once) How do I get about doing it? Sincere Thanks CAD Code: <html> <head> <title>Testing with PinPad</title> <div align="center"> <script language="JavaScript"> document.logonForm.autocomplete='off'; function setPin(ctl) { var pinVal = document.logonForm.login_pin.value; ctlValue =cutSpaces(ctl.value); if(ctlValue=='Clear'){ document.logonForm.login_pin.value = '';} else if(ctlValue=='x') { } else { if(pinVal.length==6) { document.logonForm.pin.value = ''; } else { document.logonForm.login_pin.value = pinVal + ctlValue; } } } function cutSpaces(s) { var s1, x; x = s1 = ""; l = s.length; for(i = 0; i < l; i++) if((x = s.charAt(i)) != " ") s1+=x; return s1; } </script> <script language="javascript"> document.logonForm.login_userid.focus(); </script> </head> <form method="post" action="" name="logonForm"> <table width="550" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <td> <div align="left" class="Headline1">ViA ONLINE - LOGIN WITH PIN PAD</div><hr> </td> </tr> </table> <div align="center" class="Error"><br></div> </td> </tr> </table> <table width="550" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="393"> <table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <td width="42%"> <div align="left">CUSTOMER NUMBER</div> </td> <td width="58%"> <div align="left"><input type="text" name="login_userid" class="TopTextbox" value=""></div> </td> </tr> <tr> <td width="42%"> <div align="left">PASSWORD</div> </td> <td width="58%"> <div align="left"><input type="password" name="login_password" class="TopTextbox" value=""></div> </td> </tr> <tr> <td width="42%"> <div align="left">PIN</div> </td> <td width="58%"> <div align="left"> <input type="password" name="login_pin" class="pin_textbox" value="" readonly="readonly" > <br>Enter using Pin Pad </div> </td> </tr> <tr> <td></td> <td><div align="left"><input type="submit" name="login_submit" class="Button1" value="LOGIN"> </div></td> </tr> </table> </td> <td width="157"><div align="left"> <table width="105" border="0" align="right" cellpadding="1" cellspacing="1" bgcolor="#C2C2C2"> <tbody> <tr> <td> <input name="firstbutton" value="pinpad_0" type="hidden"> <table width="100%" height="112" border="0" cellpadding="1" cellspacing="1"><tbody><tr><td colspan="3"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tbody> <tr> <td border="1" colspan="3" id="titleBar" style="cursor: move;" class="pinpad_key" bgcolor="#246584" nowrap="nowrap"> <center> <font color="white"><b> Pin Pad</b></font></center> </td> </tr> </tbody> </table> </td> </tr> <tr> <td height="22" align="center"> <input class="pinpad" tabindex="4" name="pinpad_0" value='5' onclick="setPin(this)" type="button"> </td> <td align="center"> <input class="pinpad" tabindex="4" name="pinpad_6" value="3" onclick="setPin(this)" type="button"> </td> <td align="center"> <input class="pinpad" tabindex="4" name="pinpad_5" value="4" onclick="setPin(this)" type="button"> </td> </tr> <tr> <td height="22" align="center"> <input class="pinpad" tabindex="4" name="pinpad_7" value="6" onclick="setPin(this)" type="button"> </td> <td align="center"> <input class="pinpad" tabindex="4" name="pinpad_4" value="1" onclick="setPin(this)" type="button"> </td> <td align="center"> <input class="pinpad" tabindex="4" name="pinpad_8" value="9" onclick="setPin(this)" type="button"> </td> </tr> <tr><td height="22" align="center"> <input class="pinpad" tabindex="4" name="pinpad_9" value="2" onclick="setPin(this)" type="button"> </td> <td align="center"> <input class="pinpad" tabindex="4" name="pinpad_1" value="7" onclick="setPin(this)" type="button"> </td> <td align="center"> <input class="pinpad" tabindex="4" name="pinpad_2" value="8" onclick="setPin(this)" type="button"> </td> </tr> <tr><td height="22" align="center"> <input class="pinpad" tabindex="4" name="pinpad_3" value="0" onclick="javascript:setPin(this)" type="button"> </td> <td colspan="2" align="center"> <input class="pinpad_clear" tabindex="4" name="pinpad_clear" value="Clear" onclick="setPin(this)" type="button"> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </div> </td> </tr> </table> <table width="550" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <td><br><hr> </form> </html> Similar TutorialsI've looked for a solution to this issue, but it seems like a little different scenario than other situations. I made a system for generating friend requests on Facebook. I have a grid that is 6 x 3, for a total of 18 cells. Each cell has a picture in it, and the picture is linked to the Facebook friend request page. My problem is that since each cell is populated at random from the array, I'm getting lots of repeats. For example, some picutures are in 5 cells, and some are in none. I'm trying to figure out how to make it so that once a picture is used once in the grid, it does not get used again in the same grid. I still want every cell filled at random on each page load, I just want to prevent the repeating. Here's my current code: Code: <script type="text/javascript"> var vip_list=new Array( new Array('http://profile.ak.fbcdn.net/v225/1616/88/s1220771654_2158.jpg','http://www.facebook.com/addfriend.php?id=1220771654'), new Array('http://profile.ak.fbcdn.net/v223/1233/29/s904885342_9055.jpg','http://www.facebook.com/addfriend.php?id=904885342'), new Array('http://profile.ak.fbcdn.net/v229/1574/66/s1752031238_626.jpg','http://www.facebook.com/addfriend.php?id=1752031238'), new Array('http://profile.ak.fbcdn.net/v223/768/71/n661155042_7325.jpg','http://www.facebook.com/addfriend.php?id=661155042'), new Array('http://profile.ak.fbcdn.net/v226/732/26/n1827289885_2478.jpg','http://www.facebook.com/addfriend.php?id=1827289885'), new Array('http://profile.ak.fbcdn.net/v229/1631/70/s1425313768_1140.jpg','http://www.facebook.com/addfriend.php?id=1425313768'), new Array('http://static.ak.fbcdn.net/pics/s_silhouette.jpg','http://www.facebook.com/addfriend.php?id=1667023416'), new Array('http://profile.ak.fbcdn.net/v225/1146/29/s506485704_9532.jpg','http://www.facebook.com/addfriend.php?id=506485704'), new Array('http://profile.ak.fbcdn.net/profile6/270/32/s692160490_8745.jpg','http://www.facebook.com/addfriend.php?id=692160490'), new Array('http://profile.ak.fbcdn.net/v229/114/83/s1218176198_7375.jpg','http://www.facebook.com/addfriend.php?id=1218176198'), new Array('http://profile.ak.fbcdn.net/v226/946/4/s1470171885_4973.jpg','http://www.facebook.com/addfriend.php?id=1470171885'), new Array('http://static.ak.fbcdn.net/pics/s_silhouette.jpg','http://www.facebook.com/addfriend.php?id=1329505888'), new Array('http://static.ak.fbcdn.net/pics/s_silhouette.jpg','http://www.facebook.com/addfriend.php?id=1325496968'), new Array('http://profile.ak.fbcdn.net/v223/1546/92/s1536913202_2017.jpg','http://www.facebook.com/addfriend.php?id=1536913202'), new Array('http://static.ak.fbcdn.net/pics/s_silhouette.jpg','http://www.facebook.com/addfriend.php?id=1624715433'), new Array('http://profile.ak.fbcdn.net/v228/1282/58/s713998257_3682.jpg','http://www.facebook.com/addfriend.php?id=713998257') ); var chosen_vip=Math.floor(vip_list.length*Math.random()); var chosen_vip1=Math.floor(vip_list.length*Math.random()); var chosen_vip2=Math.floor(vip_list.length*Math.random()); var chosen_vip3=Math.floor(vip_list.length*Math.random()); var chosen_vip4=Math.floor(vip_list.length*Math.random()); var chosen_vip5=Math.floor(vip_list.length*Math.random()); var chosen_vip6=Math.floor(vip_list.length*Math.random()); var chosen_vip7=Math.floor(vip_list.length*Math.random()); var chosen_vip8=Math.floor(vip_list.length*Math.random()); var chosen_vip9=Math.floor(vip_list.length*Math.random()); var chosen_vip10=Math.floor(vip_list.length*Math.random()); var chosen_vip11=Math.floor(vip_list.length*Math.random()); var chosen_vip12=Math.floor(vip_list.length*Math.random()); var chosen_vip13=Math.floor(vip_list.length*Math.random()); var chosen_vip14=Math.floor(vip_list.length*Math.random()); var chosen_vip15=Math.floor(vip_list.length*Math.random()); var chosen_vip16=Math.floor(vip_list.length*Math.random()); var chosen_vip17=Math.floor(vip_list.length*Math.random()); document.write('<center>'); document.write('<a href="',vip_list[chosen_vip][1],'" target="_blank"><img src="',vip_list[chosen_vip][0],'" height="60" width="60"></a>'); document.write('<a href="',vip_list[chosen_vip1][1],'" target="_blank"><img src="',vip_list[chosen_vip1][0],'" height="60" width="60"></a>'); document.write('<a href="',vip_list[chosen_vip2][1],'" target="_blank"><img src="',vip_list[chosen_vip2][0],'" height="60" width="60"></a>'); document.write('<a href="',vip_list[chosen_vip3][1],'" target="_blank"><img src="',vip_list[chosen_vip3][0],'" height="60" width="60"></a>'); document.write('<a href="',vip_list[chosen_vip4][1],'" target="_blank"><img src="',vip_list[chosen_vip4][0],'" height="60" width="60"></a>'); document.write('<a href="',vip_list[chosen_vip5][1],'" target="_blank"><img src="',vip_list[chosen_vip5][0],'" height="60" width="60"></a>'); document.write('<br>'); document.write('<a href="',vip_list[chosen_vip6][1],'" target="_blank"><img src="',vip_list[chosen_vip6][0],'" height="60" width="60"></a>'); document.write('<a href="',vip_list[chosen_vip7][1],'" target="_blank"><img src="',vip_list[chosen_vip7][0],'" height="60" width="60"></a>'); document.write('<a href="',vip_list[chosen_vip8][1],'" target="_blank"><img src="',vip_list[chosen_vip8][0],'" height="60" width="60"></a>'); document.write('<a href="',vip_list[chosen_vip9][1],'" target="_blank"><img src="',vip_list[chosen_vip9][0],'" height="60" width="60"></a>'); document.write('<a href="',vip_list[chosen_vip10][1],'" target="_blank"><img src="',vip_list[chosen_vip10][0],'" height="60" width="60"></a>'); document.write('<a href="',vip_list[chosen_vip11][1],'" target="_blank"><img src="',vip_list[chosen_vip11][0],'" height="60" width="60"></a>'); document.write('<br>'); document.write('<a href="',vip_list[chosen_vip12][1],'" target="_blank"><img src="',vip_list[chosen_vip12][0],'" height="60" width="60"></a>'); document.write('<a href="',vip_list[chosen_vip13][1],'" target="_blank"><img src="',vip_list[chosen_vip13][0],'" height="60" width="60"></a>'); document.write('<a href="',vip_list[chosen_vip14][1],'" target="_blank"><img src="',vip_list[chosen_vip14][0],'" height="60" width="60"></a>'); document.write('<a href="',vip_list[chosen_vip15][1],'" target="_blank"><img src="',vip_list[chosen_vip15][0],'" height="60" width="60"></a>'); document.write('<a href="',vip_list[chosen_vip16][1],'" target="_blank"><img src="',vip_list[chosen_vip16][0],'" height="60" width="60"></a>'); document.write('<a href="',vip_list[chosen_vip17][1],'" target="_blank"><img src="',vip_list[chosen_vip17][0],'" height="60" width="60"></a>'); document.write('<br>'); </script> Any suggestions? Thank you! Hi, I'm not much of a programmer, I have this script for randomly rotate a bunch of pictures. What do you change to make to change from one another, not random? Thanks Denny <script language="javascript"> var delay=5000 //set delay in miliseconds var curindex=0 var i = 0 var randomimages=new Array() randomimages[0]="...image01.jpg" randomimages[1]="...image02.jpg" randomimages[2]="...image03.jpg" randomimages[3]="...image04.jpg" randomimages[4]="...image05.jpg" randomimages[5]="...image05.jpg" var preload=new Array() for (n=0;n<randomimages.length;n++) { preload[n]=new Image() preload[n].src=randomimages[n] } i = Math.floor(Math.random()*(randomimages.length)) document.write('<img border=2 name="defaultimage" src="'+randomimages[i]+'">') function rotateimage() { if (curindex==(tempindex=Math.floor(Math.random()*(randomimages.length)))) { curindex=curindex==0? 1 : curindex-1 } else curindex=tempindex document.images.defaultimage.src=randomimages[curindex] } setInterval("rotateimage()",delay) </script> hey. im working on a facebook app.. this is what i got so far. PHP Code: <script language="JavaScript"> <!-- var theImages = new Array() theImages[0] = "http://img688.imageshack.us/img688/4787/logo1tq.jpg" theImages[1] = "http://img641.imageshack.us/img641/8292/logo2yex.jpg" theImages[2] = "http://img864.imageshack.us/img864/4097/logo3ik.jpg" theImages[3] = "http://img543.imageshack.us/img543/9046/logo4pu.jpg" theImages[4] = "http://img21.imageshack.us/img21/2567/logo5q.jpg" theImages[5] = "http://img842.imageshack.us/img842/696/logo6o.jpg" theImages[6] = "http://img85.imageshack.us/img85/7831/logo7k.jpg" var j = 0 var p = theImages.length; var preBuffer = new Array() for (i = 0; i < p; i++){ preBuffer[i] = new Image() preBuffer[i].src = theImages[i] } var whichImage = Math.round(Math.random()*(p-1)); function showImage(){ document.write('<img src="'+theImages[whichImage]+'">'); } //--> </script> <script language="JavaScript"> <!-- showImage(); //--> </script> now i want that the app posts the random image automaticlly to the useres timeline.. for example: if the random image is theImages [3] then it should post the image theimage [3] to the users timeline.. i see alot of facebook apps doing this.. thanks in advance I've started studying JavaScript recently. The following simple scenario from the Russian textbook cannot be implemented on my PC. Code: <HTML> <HEAD> <TITLE>Object Math Example</TITLE> </HEAD> <BODY> <h1>Object Math Example</h1> <p>Насколько случайны числа, полученные генератором случайных чисел? Подсчитаем среднее 5000 случайных чисел.</p> <SCRIPT LANGUAGE="JavaScript"> total = 0; for (i = 0; i<5000; i++) { num = Math.random(); total += num; document.status = "Generated " + i + " numbers"; } average = total / 5000; average = Math.round(average * 1000 / 1000); document.write("<h2>" arithmetic mean of random numbers + average + "</h2>"); </SCRIPT> </BODY> </HTML> I just typed the script char by char. I use Firefox browser, v.3.5.7. The error console does not display any mistakes. Please, explain me what is wrong in the code. I recently decided to organize my bags on http://www.coach-bag.org/category-1-...+Handbags.html - I labelled all the boxes, making sure each box had only one purse in it's dustbag and organized by season. I have 14 at the moment - 4 for Spring/Summer and 10 for Fall/Winter. I actually (OK, this is going to sound oh-so-anal) did up a schedule by week and purse and will change over every Sunday morning. I did the schedule until the end of January and each purse only gets into rotation twice - that's not very much and I hate the idea of things not getting adequate usage. And it really got me thinking as to what else I really need - but then again, who needs 14 purses, right? We all know this isn't about need. So that got me thinking about something mentioned in another thread. I have a price point in my head that I'm not comfortable going over per bag and it's $400. I had a brief moment when I considered the floral Sophia, but once I saw the modelling shots and figured out she was too big, I dismissed it and was a little relieved to do so. But with 14 bags not getting into rotation that often, I'm wondering if I should change my mindset to buy 2-3 more expensive bags per year rather than what I did in this first 14 months of Coach collecting - which was buy 14 (plus all the wallets, scarves, keyfobs and other goodies). If I do that again this year, that means I could be close to 30 purses, and honestly, I'm not comfortable with that many bags - not from the financial standpoint - just the usage or lack thereof standpoint. It seems like a lot of you ladies do spend the big bucks on bags - and lots of them - and that's great. I'm not independently wealthy, and I refuse to run a credit card balance for purses, so I only buy what I can afford and usually wait for PCE. And I guess I love a deal more than I love any individual purse, so it will really be a change in mind set for me to pay maybe $1000 for a bag maybe 2-3 times a year instead of what I've done this past 14 months where I bought 14 bags - mostly at 25%, 40% or outlet pricing. I know for some of you ladies who have DOZENS of bags, my 14 must seem minuscule and you probably think I'm nuts for thinking so hard about it - but I need to find the right balance, and I guess I'm just trying to sort that out. Does anyone else think so hard about this silly little topic or is it just me? Thanks for letting me unload my thoughts here!! I need to write something like this: http://justsheri.com/webscripting/wsassignment/1049950/ If you look at the code there is 52 of these <img src = './images/blank1.png' onClick='clickCard("qh",0)'/> where clickcard("numchanges", increments by 1) how is this done? Thanks Danny Hi, I have this bit of java code that puts a random/unique number in a field on my web page: <html> <head> </head> <body> <form> <input type="text" name="MyField" /> </form> <script langueage="javascript" type="text/javascript"> var d = new Date(); var tm = d.getTime(); document.getElementsByName('MyField')[0].value=tm; </script> </body> </html> My problem is that I want to limit the number to just 6 digits. Is this possible? Any help would be much appreciated Thank you Dave This is quite easy yet hard. I'm trying to apply something in my forums, where a member could post something let's say: "Hi, I am number [random]1, 6[/random]" And what would happen is that, a number from 1 to 6 would be the content, for example, it would be: "Hi, I am number 3" But if you refresh the page, it would still be the same number. Like it won't be randomized again. So how do I make a javascript/html code that would make a one time number randomizer. Hi i have set up a token key to give me some extra protection against direct url access to the page but i wanted to make it random. at first i used session token but it is not set until after a page refresh on login so this has to be its own deal.. i have found several javascript random codes but how to i pass that value to the window call.. here is the window call.. as you can see right know i have it hard coded as one token all the time. i just need it random and then sha1 (or md5) Code: function url_chat(){ chatwindow = window.open("<?=$CONST_MY_ROOT?>/mychat/chat/index.php?tok=0ed61bdd3a8a86f39e6b4abd01ba4e3649d0ec1c", "chatwindow", "location=0,status=0,scrollbars=0,menubar=0,resizable=0,width=950,height=550"); } i could use this i guess but i dont know how to get that value to the window call above. Code: document.write(Math.floor(Math.random()*999999999999999999)); Alright, I need a little help with my javascript. I'm a bit of a novice when it comes to programming so I apologize if this appears trivial. I have an element ID that begins with bb + a randomized number between 1-100,000. This number changes after every action so what I need is a way to retrieve this new value each time and implement it into my code. I can view the number using firebug but I need a way to automate this process. Do any of you have some advice about how I could approach this problem? I can generate a random number between 1 and 9, ( var rand_no = Math.floor( 1 + Math.random() * 9 ); ) but I want to add that random number to a value that is enterred into an inputbox and get a total. How can I do this using Javascript and put the result into a hidden field. I will also need to use that same random number in another place on another form . Thanks Hello! I have an array of strings, like this: var strings= [ "car", "black", "word", "small", "paper", "doom", "elemental", "sword", "mouse" ]; Now i got a function newgame() and i wanna display random word from this array in rectangles gray styled... Here is the problem. I can make to display random words, but i dont know how i make this words with the css style together - rectangels around a char. But the words are different length so i dunno? When i press newgame button, i want for example to random a word from the array: for example word "paper" then i want it to be displayed like this [p] [a] [p] [e] [r], where [ ] are rectangels around the chars ( with the css style, like this: border: 1px solid #000; width:10px; background-color:gray; text-align:justify; padding: 5px 10px; i make a gray rectangle border around the char, but how can i make it work with random words? How can i make it work? Any help please! I have a text file(quotes.txt) with 35+ quotations, separated by a single line break. Is it possible for a DIV to display a random quotation from quotes.txt each time the user visit my home page?
Dear all, I would like to use javascript that prints randomly one string to the string, from an array of predefined string. How do you think I should start thinking that? Alex is there a way to take my random shuffle script that displays the array like this red, yellow, blue, green, black, grey and make it so that it would list them like this red yellow blue green black grey Code: <script type="text/javascript"> function myFunction() { document.getElementById("demo").style.display="block"; var myarray=["red","blue", "yellow", "green","black", "grey"] myarray.sort(function() {return 0.5 - Math.random()}) var x=document.getElementById("demo").innerHTML=myarray; var t=setTimeout(alertMsg,10000); } function alertMsg() { document.getElementById("demo").style.display="none"; } </script> <button onclick="myFunction()">Twister Drill</button> <font size="5" color="white"> <p id="demo"><br/></p> </font> Hi. Now I know this is a fairly easy task, but I need to show the random div from a selection of 10 which all have the same class. I am not able to do this using unique IDs as the divs will be created by the end user as a repeating region from Adobe contribute. So I'll have a list looking something like the following but I only want one to show. Any ideas? Code: <div class="mydiv">Line Number One</div> <div class="mydiv">Line Number Two</div> <div class="mydiv">Line Number Three</div> <div class="mydiv">Line Number Four</div> <div class="mydiv">Line Number Five</div> <div class="mydiv">Line Number Six</div> <div class="mydiv">Line Number Seven</div> <div class="mydiv">Line Number Eight</div> <div class="mydiv">Line Number Nine</div> <div class="mydiv">Line Number Ten</div> Hi, im trying to make a quiz. Now, what I have realized is that I can make a random number coincide with a question. But then I'd have to do a huge amount of if statements. Is there a MUCH simpler way of doing this? And also the questions CAN NOT repeat. Please try and keep it simple, as I'm trying to learn. There's 10 questions by the way. Thanks in advance! Forgive me if this is in the wrong forum as I am unsure as to whether this should be PHP or Java, or a WP plugin. Basically I need to have a slideshow that picks images from a folder without the need to use arrays as there will be a large amount of images and I need to literally be able to drop images in a folder and they appear in a random order within the slideshow. As you can appreciate with a large amount of images, the code needs to call them as and when needed rather than loading them in at the beginning. I have been using Wordpress's nextgen gallery and have been hacking away at a few plugins etc, and the closest I have come is to make WP select a different post with gallery each time creating the illusion that the images are in a different order, however this isn't going to be ideal as its not truly random, and breeds duplicates. If I have to stay away from WP that's fine, uploading to an ftp would be ok. Hope someone can point me in the right direction! Thank You A What I am doing is working on a shooting app that will randomly call out different targets to shoot. I have it so it will randomly organize them but I need it so it pulls a single one. Any help would be appreciated! Code: <html> <body> <p id="demo">Click the Button to Call out a target</p> <button onclick="myFunction()">Call Out</button> <script type="text/javascript"> function myFunction() { var myarray=["red","blue", "yellow", "orange"] myarray.sort(function() {return 0.5 - Math.random()}) var x=document.getElementById("demo"); x.innerHTML=myarray; } </script> </body> </html> ***I need to randomise the order of some questions that are in this format. Any ideas? Thank you!*** <CODE> <!---Question4---> <form name="form4" method="post" action=""> <h3><p>First One</p></h3> <p> <label><input type="radio" name="q4" id="w1" value="1" </label> <label><input type="radio" name="q4" id="w2" value="2" </label> <label><input type="radio" name="q4" id="w3" value="2" </label> </p> </form </CODE> |