Jump to content

Search the Community

Showing results for tags 'random'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Calendars

  • Community Calendar

Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 10 results

  1. Problem with random

    I intend to make lottery drawing program but first wanted to check the basic random module with a code: from random import * print(randint(1, 100)) Instead I receive a comment from cmd that contains output of some other file that I created None of my files is named random.py. I have no idea how is this possible.
  2. Hello, I'm trying to make a spinner that spins randomly on click (see example below). I've been messing around with this for hours, but I just cannot make this work like I want it to. This is my code, but it is unfinished and buggy: var myArray = ['360', '330', '300', '270', '240', '210', '180', '150', '120', '90', '60', '30']; var Spinner1 = sym.$('Spinner1'); // spinner 1 = wheel.jpg Spinner1.click(function(){ // randomize the degree of spin. var mySpin = myArray[Math.floor(Math.random() * myArray.length)]; sym.getSymbol('Spinner1').play(); Spinner1.css({ '-webkit-transform': 'rotate(' + mySpin + 'deg)', '-moz-transform': 'rotate(' + mySpin + 'deg)', '-ms-transform': 'rotate(' + mySpin + 'deg)', '-o-transform': 'rotate(' + mySpin + 'deg)', 'transform': 'rotate(' + mySpin + 'deg)', }); Spinner1.css('-webkit-transition','all 500ms cubic-bezier(0.420, 0.000, 1.000, 1.000)'); // calling alert pop-up on number if (mySpin > 330 && mySpin < 360) { alert("Winner is number 1!"); } }); What I am actually trying to achieve is the following: The spinner only spins clockwise (not clockwise and counter-clockwise) The spinner always spins 360 degrees + the random number/degrees defined in myArray (added on top of 360deg) The spinner randomly picks a number/degrees from myArray - but does not repeat that number again until all numbers have been spinned (resets after all spins) The spinner calls an alert pop-up when the pointer has landed on a number (between 1-12) If anyone can help me out or perhaps make my code work properly, I would be very happy. I really want to know what I am doing wrong so I can learn from it in the future. Help is sincerely appreciated! Regards, Entity_101 TestSpinner.zip
  3. Randomly Changing Color

    Hey, so I have a question regarding my previous post. I am trying to randomly change the color of a div just by ppressing it. Here is my code to do so: My html: <button onclick="changeShirtColorRandom()">Change Shirt Color Random</button> My javascript: function color(color){ this.color = color;}//*All colorsvar red = new color("red");var blue = new color("blue");var green = new color("green");var purple = new color("purple");var yellow= new color("yellow");var black = new color("black");//*Array of colorsvar colors = [red, blue, green, purple, yellow, black]; //*Function that chooses a random shirt colorfunction changeShirtColorRandom{ var num = Math.floor(Math.random() * colors.length); var colors_obj = "'" + colors[num] + "'"; document.getElementById("torsoColorChange").style.backgroundColor = colors_obj; document.getElementById("right-sleeveColorChange").style.backgroundColor = colors_obj; document.getElementById("left-sleeveColorChange").style.backgroundColor = colors_obj;} This is just the part of the code that is relevant. The problem is when I click the button nothing happens. What is wrong with my code?
  4. Random Links

    Hey so I am creating just a fun program where you can mix and match different tops, pants, and shoes. When you click an arrow button it changes the top, pants, or shoes. My code is not work. Please help, I think the problem is the way the link are placed. Please help. Here is my html: <!DOCTYPE html><html><head> <link rel='stylesheet' href='style.css'/> <script src='script.js'></script></head><body> <div class = "top"><div id = "randomtop"></div></div> <div id = "topright" onclick="toprightfnc()"><img class = "imgright" src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALMAAAEaCAMAAABtrpZTAAAAM1BMVEX///+/v7+8vLzd3d3b29vBwcHs7OzMzMz7+/vX19fr6+vOzs709PTExMTg4ODn5+f29vaQxP3sAAAC50lEQVR4nO3d227iQBCE4eCEZMkCyfs/7bKKUAz4MB5Puqviv665+DTqLkuW8Dw9FeR8LvmVVM5d54Y+d7udGfr5QjZDf5Gt0FeyEfqbbIPuk03Qt2QL9D3ZAP1IlkcPkcXRw2Rp9BhZGD1OvqCfs3WDmSKLoqfJkug5siD6ZZYsh54/ZTl0GVkKXUoWQpfMshh6CVkEvYwsgV5KFkAvJ6eja8jJ6DpyKrqWnIiuJ6eh15CT0OvIF/SLHTkBvZ4cjm5BDka3IceiPxqZQYMGDboWfXBEW540aNCgq/PuWHmgQYMGDRo0aNCgQYPeGPrVEf3eyAx6LpbjARo0aAV0I7Mp+q8jmpkGDRp0Hdqy8kCDFkFbLiJo0OM5NjLTHqBBr8jRsj1AR6EbmUHPoveG6FdHtOd4gAY9gebhEoW2rDzQoCfQjcygQcugLRcRtB36zRFNe4CeQAfO9KcjeuPtARq0BtqyPUCHoR1n2nIRPdEnQ/TZ71XvRyPxbrc/RpFbnTLkGPIn5ACy4WAYkg0HAzJkyJCLc/IjG54yZMiQ08iGJQf5V5GbvS2KWz/IkH+Y7Ld+HWTIg4EcQd7/gQz5Md3JkGy3fpAhD8dv/QxLzpBs2cuGZLvGgDyR8kuRZ8lRs9yMHPcoaUcO6+UtDwZkyJAhQ1YjB4k3fsp+5DfIAWTDwQgjt7rg25McJN42OawxIEOGfE+mlyEPksP+Crrp9YM8ngNkK3JYyUH2Ioc9Sja9fpAh/xpykBgy5B8nG64f5PG0ugo9kNwKHfl9qEboYHILdDh5/f3tCeS16BTyuvGI/AjvTerv5ksj1590Irn2pJNmeQ06mVyDTicvv5tPgLy0pyXIy9CpjdFP+UzLkMvRQuRStBS5DC1GLkGLNEY/cz0tSJ5DS5Kn0XKzfM04WpY8vojC5DG0NHkYLU4eQsuTH9EG5Pv2sCDfok3IfbQN+RttRL6irchft9Wakf+j7cgX9CFb0M8/kH9frqpfpFQAAAAASUVORK5CYII="></img></div> <div id = "topleft"><img class = "imgleft" src = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcR1pyUMwdx_XBdS_318Mi-l39JKwwmrTJ6onBiVNM-WpyEul9Er"></img></div> <div class = "moretop"></div> <div class = "pants"></div> <div id = "pantsright"><img class = "imgright" src = "data:image/png;base64,iVBORw0KGgoAAAANSUh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5Pv2sCDfok3IfbQN+RttRL6irchft9Wakf+j7cgX9CFb0M8/kH9frqpfpFQAAAAASUVORK5CYII="></img></div> <div id = "pantsleft"><img class = "imgleft" src = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcR1pyUMwdx_XBdS_318Mi-l39JKwwmrTJ6onBiVNM-WpyEul9Er"></img></div> <div class = "morepants"></div> <div class = "shoes"></div> <div id = "shoesright"><img class = "imgright" src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALMAAAEaCAMAAABtrpZTAAAAM1BMVEX///+/v7+8vLzd3d3b29vBwcHs7OzMzMz7+/vX19fr6+vOzs709PTExMTg4ODn5+f29vaQxP3sAAAC50lEQVR4nO3d227iQBCE4eCEZMkCyfs/7bKKUAz4MB5Puqviv665+DTqLkuW8Dw9FeR8LvmVVM5d54Y+d7udGfr5QjZDf5Gt0FeyEfqbbIPuk03Qt2QL9D3ZAP1IlkcPkcXRw2Rp9BhZGD1OvqCfs3WDmSKLoqfJkug5siD6ZZYsh54/ZTl0GVkKXUoWQpfMshh6CVkEvYwsgV5KFkAvJ6eja8jJ6DpyKrqWnIiuJ6eh15CT0OvIF/SLHTkBvZ4cjm5BDka3IceiPxqZQYMGDboWfXBEW540aNCgq/PuWHmgQYMGDRo0aNCgQYPeGPrVEf3eyAx6LpbjARo0aAV0I7Mp+q8jmpkGDRp0Hdqy8kCDFkFbLiJo0OM5NjLTHqBBr8jRsj1AR6EbmUHPoveG6FdHtOd4gAY9gebhEoW2rDzQoCfQjcygQcugLRcRtB36zRFNe4CeQAfO9KcjeuPtARq0BtqyPUCHoR1n2nIRPdEnQ/TZ71XvRyPxbrc/RpFbnTLkGPIn5ACy4WAYkg0HAzJkyJCLc/IjG54yZMiQ08iGJQf5V5GbvS2KWz/IkH+Y7Ld+HWTIg4EcQd7/gQz5Md3JkGy3fpAhD8dv/QxLzpBs2cuGZLvGgDyR8kuRZ8lRs9yMHPcoaUcO6+UtDwZkyJAhQ1YjB4k3fsp+5DfIAWTDwQgjt7rg25McJN42OawxIEOGfE+mlyEPksP+Crrp9YM8ngNkK3JYyUH2Ioc9Sja9fpAh/xpykBgy5B8nG64f5PG0ugo9kNwKHfl9qEboYHILdDh5/f3tCeS16BTyuvGI/AjvTerv5ksj1590Irn2pJNmeQ06mVyDTicvv5tPgLy0pyXIy9CpjdFP+UzLkMvRQuRStBS5DC1GLkGLNEY/cz0tSJ5DS5Kn0XKzfM04WpY8vojC5DG0NHkYLU4eQsuTH9EG5Pv2sCDfok3IfbQN+RttRL6irchft9Wakf+j7cgX9CFb0M8/kH9frqpfpFQAAAAASUVORK5CYII="></img></div> <div id = "shoesleft"><img class = "imgleft" src = "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcR1pyUMwdx_XBdS_318Mi-l39JKwwmrTJ6onBiVNM-WpyEul9Er"></img></div> <div class = "moreshoes"></div></body></html> And here is my javascript: function picture(img) { this.link = link;}//*All clothingvar top = new picture(https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQqsdG9ZJSEOvFjdUC3Z8SpHh02ML1kbmoq-zF8thO6OiPRESR_);var top2 = new picture(https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQqsdG9ZJSEOvFjdUC3Z8SpHh02ML1kbmoq-zF8thO6OiPRESR_);var pants = new picture();var pants2 = new picture();var shoes = new picture();var shoes2 = new picture();//*All topsvar tops = [top, top2];//*All pantsvar pants = [pants, pants2];//*All shoesvar shoes = [shoes, shoes2];//*topright random generatorfunction toprightfnc(){ var random = Math.floor(Math.random() * tops.length); var tops_generate = tops[random]; document.getElementById("randomtop").innerHTML = tops_generate.link;} Why isn't it working?
  5. Random word in prompt

    Hey, so I have another question about how to write a function. What I have is a prompt, that asks, what does "..." mean? What I want is a function that randomly chooses a word from a dictionary to enter in the quotation marks. Here is my dictionary: var translation = {};// Spanish dictionarytranslation.spanish = {};translation.spanish["gato"] = "cat";translation.spanish["perro"] = "dog";translation.spanish["hola"] = "hello";// English dictionarytranslation.english = {};translation.english["cat"] = "gato";translation.english["dog"] = "perro";translation.english["hello"] = "hola"; There are two buttons. When I press the spanish button I want a spanish word to go in the quotes, and I would respond with the word translated in english. When I press the english button I want an english word to go in the quotes, and I would respond with the word translated in spanish. I would use this to review spanish vocab. How would I make a function that randomly chooses a word to go in the quotes. I know I would have to use math.random, but otherewise I do not know how to set it up. Please provide suggestions and ideas, thanks!
  6. Hello, I'm currently working on a school project involving a bunch of coding in html, css and js. The project's purpose is to basically build a website containing a 'quiz' system. I've already managed to successfully create one, but I'm not yet fully satisfied with it. The quiz contains 21 questions in total, and each question has their own html page; 21 pages in total. Now I have been using a java code to call a random page when a button is pressed on the home website (index.html). It works properly, but it often redirects me to the same page every time I click the button. I want to prevent it from visiting the same page whenever the button is pressed, until all 21 pages have been visited, at which point it resets the data and starts over. I have been looking for a kind of script for this, but can't seem to find it. My only option would be to ask for help, which is why I'm here. This is the code I am currently using for the page randomizer: var howMany = 20; // max number of items listed below var page = new Array(howMany+1); page[0]="spelopdracht1.html"; page[1]="spelopdracht2.html"; page[2]="spelopdracht3.html"; page[3]="spelopdracht4.html"; page[4]="spelopdracht5.html"; page[5]="spelopdracht6.html"; page[6]="spelopdracht7.html"; page[7]="spelopdracht8.html"; page[8]="spelopdracht9.html"; page[9]="spelopdracht10.html"; page[10]="spelopdracht11.html"; page[11]="spelopdracht12.html"; page[12]="spelopdracht13.html"; page[13]="spelopdracht14.html"; page[14]="spelopdracht15.html"; page[15]="spelopdracht16.html"; page[16]="spelopdracht17.html"; page[17]="spelopdracht18.html"; page[18]="spelopdracht19.html"; page[19]="spelopdracht20.html"; page[20]="spelopdracht21.html"; function rndnumber(){ var randscript = -1; while (randscript < 0 || randscript > howMany || isNaN(randscript)){ randscript = parseInt(Math.random()*(howMany+1)); } return randscript; } quo = rndnumber(); quox = page[quo]; window.location=(quox); } } If there is anything you can do, please let me know. I would really appreciate your help! ^.^
  7. Hello all, I have a piece of code (created by a developer, not myself) which displays images stored on a php / mySQL database. When the cursor goes over the images they 'flip' to display some information relating to that image. The original purpose of this code was to display just one line of images. However, I would now like to display two lines of images. When I repeat the code, a couple of things happen which I don't want to happen. The second line of images don't flip back to the original image when the cursor is removed from them. The second line uses the same images as the first line. I would like separate images from the database to be chosen. The problem can be seen here in this page: http://www.senseiconnect.com/responsive%20design%20tutorial/%20OrangutanJapan%202014/OJ_template2_FlipONLY_HOME.php As you can see, both rows are pulling the same random images (these change upon refresh) and the second (lower) row of images doesn't flip back to the image like the top row. The code (not including CSS - let me know if that would help) is below: <div class="boxLine"> <!--boxLine STARTS--> <?php $i = 0; if (count($userTilesTop) > 0) foreach ($userTilesTop as $userTile){ $i++; ?> <!--box6 STARTS--> <div class="box6" id="userTile<?php echo $i; ?>"<?php if (!empty($userTile['autonumber'])) { ?>onclick="javascript:window.location='http://www.orangutanjapan.com/newsearch/Ddetails_jp.php?pageNum_m=&language=&prefecture=&recordID=<?php echo $userTile['autonumber']; ?>';return false;"<?php } ?>> <div class="box6Inner"> <!--***********box6Inner STARTS**************--> <div class='slide imageslide'> <!--slide imageslide STARTS--> <img src="http://www.orangutanenglish.com/upload/<?php echo $userTile['photoid']; ?>" alt="英会話レッスンの先生" width="136" height="116" /> <h3><?php echo ucwords($userTile['firstname']); ?> (<?php echo ucwords(eng2japPrefectures($userTile['prefecture'])); ?>)</h3> </div> <!--slide imageslide ENDS--> <div class='slide textslide'> <!--slide textslide starts STARTS--> <ul> <li>国籍: <?php echo $userTile['nationality']; ?></li> <li>対象言語: <?php echo $userTile['language']; ?></li> <li>教師経験(年): <?php echo $userTile['teachingexperience']; ?></li> <li>授業料: <?php echo $userTile['private_price']; ?>Y</li> </ul> <!-- userTileView STARTS--><div class="userTileView"><a href="<?php if (!empty($userTile['autonumber'])) { ?> http://www.orangutanjapan.com/newsearch/Ddetails_jp.php?pageNum_m=&language=&prefecture=&recordID=<?php echo $userTile['autonumber']; } ?>"><img src="http://www.orangutanjapan.com/user-profile-arrow.png" alt="View <?php echo ucwords($userTile['firstname']); ?>'s profile"></a></div><!--slide userTileView ENDS--> </div> <!--slide textslide starts ENDS--> </div> <!--***********box6Inner starts ENDS **************--> </div> <!--box6 ENDS--> <?php } ?> </div> <!--boxLine ENDS--> Many thanks for taking time to read this post.
  8. Hi , It my first post on the forum but i'm a old user of your web site. My problem is in asp i need tor creat a random fonction like loto. I explain y probleme, i have an arrey like this (19,20,21,22,23,24,25) and it can be any longueur with many number other exmple (99,100,101,104,105) What i need its too place in different order like a random this array First exemple original=(19,20,21,22,23,24,25) after (22,20,24,21,23,19,25)after (20,19,21,24,23,22,25)and ... First step i do its a code to find how number of value in array.I count the array,I repalce all , by nothing ans i recount the array now i know in how i need to split my arraybut i dont how to place my value in a different order and not 2 time every value need to be there but in a different order Sorry for my english i try my best If some body have a suggest for me its appreciate. I need to do this on a looping for a multiple insert in a bd but for that its not a problem for me Thanks you Have a nice day
  9. Hi, So I made a website that shows you a random classic movie. But I'm a developer, not a designer, so the layout isen't what it should be. So I want your opinion on some things. url: http://www.aclassicmovie.com Some people said they feel the website is to busy, specially with the background change, what do you think ? Some people also said the video is to small, and the filtering takes up to much space, how do you guys feel about it ? Any other suggestions are more then welcome! Spedax
  10. Hi, I am reworking an old web site by starting over. I have done a lot of reading on xml to make a database for random or next page link to put on all my web site pages. I have some 1500 pages so when I rebuild I probably only have 500 after cutting the less viewed pages. Anyway, I have inspyder to create gmz sitemaps but can set it to make a xml site map for a database for the web site. I use expression web to create my web site but mostly I hand code in html and a bit of php. I have been doing this since 1999 and still love html.. My problem is how to put a button on my site using the xml sitemap so I can have a next or random link on my web site. I tried using the expression web tools to do this but on my text web site it did not work. I also have zoom indexer that indexes my 11 web sites to create a search engine which I can use to create a sitemap or site index. I have been reading for two day now looking for an answer or software to buy that would allow me to add some type of button to my site so people did not have to search or go back to the navigation to find the next pages. I have found javascript but I can do the same with putting up an html button and simply putting a link to another pages. However I really wanted to find a way to do this without having to add a next buttons by hand on each new website I build so if I remove a page, I don’t have to go back and remove the html link in the future. Does anyone have any advice for an old woman? LOL ThanksKimberly
×