JavaScript - How To Create Random Question Checker ?!!
hi
i want to create one java code that do this : 1-one counter is counting 20 to 0. 2-if counter 0 then choose random string between "click one" , "click two" , "click three" and show it. 3-in other table we have three button that name`s are "one" , "two" ,"three". 4-for continue page user must click true button,if user click false button alert "wrong". thx Similar TutorialsI have used this script successfully: http://www.javascriptkit.com/script/...2/refer2.shtml However, is there a way to block the following work-around (example only): http://www.their-url.com/redir.php?u...ww.my-url.com/ The redir.php makes it possible to get past the script. How would I go about creating a random number between 1-50 that COULD include whole numbers, decimals to the tenth, hundredth and the thousandth place? Ex) 2.145, 3, 5.8, 41.002, 10.12, 7, 18.023, 33.2 Also, if the only way to do it is to put trailing zeros to the thousandth place that's fine as well ex) 2.145, 3.00, 5.800, 41.002, 10.120, 7.00, 18.023, 33.200 Very, VERY new to javascript, hopefully this question isn't too bad.. So I'm looking at an example of randomly changing a picture through a function, I want to understand *why*, not simply know how.. The confusing code for me is: Code: while (that.src.indexOf(myImages[newImgNumber]) != -1) The other code is irrelevant. My question is, why would testing a current image with a new image result in -1 if they are the same? To me, it seems like it should be !=0? I mean, if I tested if a number was the same as another number, I would expect a result of 0 by subtracting. Is it not subtracting index position to find out if they're the same? Does it simply just return -1 if they are the same, and I'm over thinking it? Thanks for any 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 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! 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..... Hey! I have a problem and i have looked all around for an anwser. I need some type of code or script to make my 3 images glow with opacity going in and out. Basically, I have 3 images on a page and I want one of the images to randomly fade in for a couple secs then fade out then repeat somewhere between 4 to 20 secs. But, all the images have the same concept going on with their own random fading in and out (without mouse over). Does anyone know of a script or anything that could do this or if anyone could help me make something like this? Not very good with JS. Thank you for taking the time. Have a good day or night I have a js counter which keeps track of how many chars are in a field on an asp form. When the user clicks a button further down in the form, the form generates more fields. This also causes the js counter to reset to its original value, as the page is 'reloading' in a way. How can I check this value and keep it the same when the user clicks this button? I am including the code I have, if anyone has any ideas/suggestions thanks javascript Code: <asp:Content ID="Content1" ContentPlaceHolderID="headContent" runat="server"> <script type="text/javascript"> //limit of chars var lim = 128; function count(a) { //difference count var dif = lim - a.value.length; while (dif < 0) { a.value = a.value.replace(/.$/, '') dif = lim - a.value.length; } //display difference count document.getElementById('myspan').firstChild.data = dif; } </script> counter in code Code: <asp:TextBox ID="txtHeadline" runat="server" Width="600px" MaxLength="128" CssClass="VariableText" onkeyup="count(this)"></asp:TextBox> </td> <td valign="middle" width="160px"> <asp:Label ID="Label14" runat="server" Font-Bold="True" Font-Names="Tahoma" Font-Size="8pt" Text="Characters Remaining: " Width="130px" CssClass="LABEL" Height="16px"></asp:Label> <span id="myspan" Font-Names="Tahoma" Font-Size="8pt">128</span> button Code: <asp:Button ID="btnInitializeTemplate" runat="server" OnClick="btnInitializeTemplate_Click" Text="Initialize Template" CssClass="LABEL" /> i have tried Code: <asp:Button ID="btnInitializeTemplate" runat="server" OnClientClick="return count(document.getElementById('txtHeadline'));" OnClick="btnInitializeTemplate_Click" Text="Initialize Template" CssClass="LABEL" /> it compiles but the value remains reset. any advice on what im doing wrong? I badly need a Javascript syntax checker for my Javascript. Any suggestionss will be gratefully received. Frank Hi, I have good script Code: <script type="text/javascript"> function chkcontrol(j) { var total=0; for(var i=0; i < document.form1.opt.length; i++){ if(document.form1.opt[i].checked){ total =total +1;} if(total > 11){ alert("No more than 11 please") document.form1.opt[j].checked = false ; return false; } } } </script> But this script works only If I have: <input type="checkbox" name="opt" value="1" onclick='chkcontrol(1)'>Opt 1 <input type="checkbox" name="opt" value="2" onclick='chkcontrol(2)'>Opt 2 I need to proces this form with PHP so, when I change opt to opt[] (<input type="checkbox" name="opt[]"..) script doesnt work anymore. Couldnt find any script for it, so help me if you can. Thank you Visitors enter information in textarea's and form fields and I wish to allow them to have this spell checked before submitting. What methods are open to me to do this. Hello, I'm building a simple custom dropdown menu for a web-site so that I can control look and feel as well as the behavior of an iframe. I've set it up so that when the user clicks on any of the menu's active components, an "if" sequence in the clickHandler() function is activated that gets the element's class. If the event occurred on a dropdown option, the event-target id is checked, and the appropriate function is called. At least this is how it's supposed to work. All of the drop-down options have been assigned the "dmo" class. When I test the menu and click on other elements, it works fine. But when I click the "dmo" drop-down options, nothing happens. Firebug and IE Explorer Developer Tools both show no errors, but on clicking a dropdown option, the correlate code doesn't run at all, and after hours of head-banging, I have no idea why. I need help on this one. Here's the code. Code: <!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> <style type="text/css"> BODY { background:#000; } .DropMenu { width:228px; height:1.5em; } .DropMenu span { color:#FFF; font-size:0.875em; font-family:Verdana, Geneva, sans-serif; font-weight:bold; } .DropMenuLabel { float:left; width:85px; height:1.5em; padding:0.2em 0 0 0; text-indent:0.3em; } .DropMenuTopList { width:130px; float:left; height:1.5em; padding:0 0 0 0; cursor:pointer; } .DropMenuTopList img { padding:0.4em 0 0 0.3em; cursor:pointer; } .DropMenu span { color:#FFF; font-size:.875em; font-family:Verdana, Geneva, sans-serif; font-weight:bold; vertical-align:center; } #dropMenuButton { cursor:pointer; } #dropMenuOptions { position:relative; width:130px; left:85px; padding:0.2em 0 0 0; visibility:hidden; cursor:pointer; } .MenuList { list-style-type:none; top:0; left:0; width:100%; margin:1.5em 0 0 0; padding:0; } .MenuList li{ height:1.5em; margin:0.2em 0 0 0; padding:0; width:100%; background-color:#666; border-color:#AAA; border:0.5px solid; text-indent:0.3em; } .dmo { z-index:100; } </style> <script type="text/javascript" language="javascript"> window.onload = function() { setBehavior(); } function setBehavior() { /* var downButton = document.getElementById('dropMenuButton') downButton.onclick = new Function ( "showMenu()" ); */ window.onclick = new Function ( "evt" , "clickHandler( evt )" ); } function clickHandler( evt ) { var dropMenu = document.getElementById('dropMenuOptions'); var e = evt; var targ; if (e.target) {targ = e.target} else if (e.srcElement) {targ = e.srcElement} var targClass = targ.getAttribute('class'); /* classnames dmb - dropdown button - this should toggle the dropdown visibility on and off on click, and toggle visibility on over/out dmo - option - once clicked, this should turn the dropdown visibility off */ var exclude = ("dmb" || "dmo") if (targClass != exclude ) { hideMenu() } else if (targClass == "dmb" ) { if (dropMenu.style.visibility == "visible") { hideMenu() } else showMenu(); } else if (targClass == "dmo" ) { if ( targ.id == "option1" ){ window.open(www.bing.com,"Bing") } else if ( targ.id == "option2" ){ window.open(www.bing.com,"Bing") } else if ( targ.id == "option3" ){ window.open(www.cuil.com,"Cuil") } hideMenu(); } } function showMenu() { var dropMenu = document.getElementById('dropMenuOptions'); dropMenu.style.visibility= "visible"; } function hideMenu() { var dropMenu = document.getElementById('dropMenuOptions'); dropMenu.style.visibility= "hidden"; } </script> </head> <body> <div id="customMenu" class="DropMenu"> <span> <div class="DropMenuLabel">Options:</div> <div class="DropMenuTopList dmb" id="dropMenuTopList">Temp Text <img class="dmb" id="dropMenuButton" src="Assets/Buttons/DropMenuDownButton.png"> </img> </div> <div class="dmo DropMenuOptions" id="dropMenuOptions"> <ul id="menuList" class="dmo MenuList"> <li id="option1" class="dmo">Option1</li> <li id="option2" class="dmo">Option2</li> <li id="option3" class="dmo">Option3</li> </ul> </div> </span> </div> </body> </html> Hey everyone, I'm new here so be gentle I ran into a website called livethesheendream.com when the whole charlie sheen drama was going on. I really liked the way the simple site was designed and would like to create something similar to the layout but totally different topic. My question is, can someone modify the script so that when someone clicks on the image or if they click on the "quote" it will show the next quote BUT in the order I want it to be, for example... it will start with "1" when the open the page, then when you click the picture or "1" it will show "2", then "3" and so on. I will write out all the quotes and have the user just click next, next, next. I hope that makes sense. I copied and posted the source code i got from livethesheendream.com if that helps. PM me if you need to, I will be online most the day. Thank you to anyone who can help me! Code: <!doctype html> <html> <head> <title>Live the Sheen Dream</title> <link href="styles/screen.css" rel="stylesheet" type="text/css" /> <meta name="description" content="A random quote generator from Charlie Sheen's recent rants and words of wisdom." /> <meta name="keywords" content="charlie sheen, sheen, quotes, quote generator, meme, charlie sheen crazy, charlie sheen insane, charlie sheen rant, rant, charlie sheen drugs, f-18, winning, charlie sheen winning" /> <meta name="robots" content="index, follow" /> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-21696467-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </head> <body> <div id="wrapper"> <center><p><a href="http://www.livethesheendream.com/" onclick="randomQuote(); return false;"><img src="http://www.livethesheendream.com/images/sheen.jpg" alt="sheen" /></a></p></center> <h4><p>( click the head. )</p></h4> <h1><blockquote id="quote">Get the cancer out of the mix.</blockquote></h1> <center> <script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http://livethesheendream.com/" layout="button_count" show_faces="false" font="arial"></fb:like> </center> <br /> <center> <a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" >Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script> </center> <br /> <center><h3> <a href="mailto:info@livethesheendream.com" target="_blank">contact us</a> </h3></center> <script type="text/javascript"> var quotes = ["Good luck on your travels. You\u2019re going to need it. Badly.","Sorry man, didn\u2019t make the rules.","I embarrassed him in front of his children and the world.","I\u2019ve got magic. I\u2019ve got poetry at my fingertips.","Mistook this rockstar, bro.","The only thing I\u2019m addicted to right now is winning.","I\u2019m not Thomas Jefferson. He was a pussy.","My success rate is 100 percent. Do the math.","I\u2019m so tired of pretending my life isn\u2019t perfect and *****in\u2019.","Imagine what I would have done with my fire-breathing fists.","Here\u2019s your first pee test. The next one goes in your mouth. No, you won\u2019t get high.","The scoreboard doesn\u2019t lie. Never has.","I am battle-tested bayonets bro.","Where there were four, there are now three.","Just sit back and enjoy the show.","I have real fame. They have nothing.","Bring me a challenge. Somebody.","Pure and complete gnarly-isms.","There\u2019s my life. Deal with it. Oh, wait, can\u2019t process it? LOSERS.","A lot of people think Major League\u2019s called Wild Thing. As they should.","Why give an interview when you can leave a warning?","There\u2019s a new sheriff in town. And he has an army of assassins.","We work for the pope.","Gnarly gnarlingtons.","I am special, and I will never be one of you.","There are parts of me that are Dennis Hopper.","I don\u2019t live in the middle anymore. That\u2019s where you get embarrassed in front of the prom queen.","Thought you were messing with one dude? Sorry.","WINNING.","WINNING.","I\u2019m going to hang out with these two smoooooking hotties and fly privately around the world.","It might be lonely up here but I sure like the view.","I\u2019m done. It\u2019s on. Bring it.","I wanted to watch Jaws on the ocean in the dark and be afraid.","This guy\u2019s got more notches on his belt than Black Bart.","This is me not on drugs bro.","The first one\u2019s free. The next one goes in your mouth.","This contaminated little maggot can\u2019t handle my power.","Clearly I have defeated this earthworm with my words.","I closed my eyes and in a nanosecond I cured myself.","Quit hiding dude. It\u2019s embarrassing. Next subject.","It\u2019s funny how sheep rhymes with sleep.","Bull S-H-I-T.","I\u2019ve spent close to the last decade effortlessly and magically converting your tin cans into pure gold.","You\u2019ve been warned dude. Bring it.","Apocalypse Now will teach you how to live inside of a moment between a moment.","I have a disease? Bull****. I cured it with my brain.","If you\u2019re a part of my family, I will love you violently.","I look at the game of baseball and I\u2019m reminded of a quote that I wrote.","They couldn\u2019t extinguish my pilot light. And that was a mistake.","I\u2019m 45, I\u2019ve got five kids, and I\u2019ve been dumped on for too long.","One of my favorite poets is Eminem.","Let\u2019s hook up and just bring fiery death.","Watch me bury you.","I don\u2019t sleep. I wait.","Let\u2019s talk about something exciting. Me.","Everybody has a black belt and carries a gun. I don\u2019t mess with people.","I\u2019m rolling out magic, bro.","Go back to the troll hole where you came from.","I\u2019m just giving them what I guess they want, I just don\u2019t know if they can handle it. Pussies.","I guess I\u2019m just that goddamn *****in\u2019.","We\u2019re Vatican assassins. How complicated can it be?","Most of the time- and this includes naps- I\u2019m an F-18.","I don\u2019t know, winning, anyone? Rhymes with winning? Anyone? Yeah, that would be us.","I have one speed. I have one gear. Go.","I dare you to keep up with me.","I am on a drug. It\u2019s called Charlie Sheen.","I\u2019m an F-18 bro.","The run I was on made Sinatra, Flynn, Jagger and Richards look like droopy-eyed armless children.","Your face will melt off and your children will weep over your exploded body.","You should have read the directions before you showed up at the party.","I\u2019ve got tiger blood, man.","Your face will melt off and your children will weep over your exploded body.","I may forget about them tomorrow, but they\u2019ll live with that memory for the rest of their lives. And that\u2019s a gift.","I was banging seven gram rocks and finishing them. Because that\u2019s how I roll.","I have a different constitution.","I use a blender. I use a vacuum cleaner.","I\u2019m bi-winning. I win here, and I win there.","What\u2019s the cure? Medicine?","You borrow my brain for five seconds and just be like 'Dude, can\u2019t handle it. Unplug this *******.'","Basically they strapped on their diapers.","I exposed people to magic.","Shut up. Stop. Move forward.","Wow. What does that mean.","Resentments are the rocket fuel that lives in the tip of my sabre.","I\u2019m tired of pretending I\u2019m not a total, *****in\u2019 rock star from Mars.","Drug tests don\u2019t lie.","It\u2019s a war. And it\u2019s on.","Sorry my life is so much more *****in\u2019 than yours. I planned it that way.","I take great umbrage with that.","I don\u2019t have burnout in my gear box.","I\u2019m just going to sail across the winds of the universe with my goddesses.","That was the America I was raised in.","If people could just read behind the hieroglyphic.","I don\u2019t think people are ready for the message I\u2019m delivering.","They picked a fight with a warlock.","Faith is for winners. Hope is for losers.","Clearly he didn\u2019t bring gum for everyone.","I\u2019m going to win every moment.","That\u2019s the code. And we all live by it.","Here\u2019s your cold coffee. Buh-bye.","Surprise. That\u2019s what winners do.","I can\u2019t make up a hernia. That\u2019s just lame.","It\u2019s a three-letter word. It rhymes with why.","My conduct is *****in\u2019.","Come on bro, I won best picture at 20.","Your perimeter\u2019s been breached. You got work to do bro.","It was so gnarly I can\u2019t remember.","I\u2019m not recovering like some pussy.","Rock bottom? That\u2019s a fishing term.","I\u2019m a grandiose life, and I\u2019m embracing it.","Can\u2019t is the cancer of happen.","Dying is for fools. Amateurs.","When I\u2019m fighting a war there\u2019s no room for sensitivity.","If you can bring me a souvenir from that moment when your father locked you in the closet, then bring it to me.","She was attacking me with a small fork.","What was she doing with a shrimp fork in her purse?","I'm still alive, which is pretty cool.","Women are not to be hit. They are to be hugged and caressed.","I have a 10,000-year-old brain and the boogers of a seven-year-old.","Get over here and enjoy the ride, bro. We\u2019re starting to win.","I\u2019m not taking it. I had to pay for it.","Vintage balderdash.","I\u2019ve been a veteran of the unspeakable.","I literally woke up and it was Christmas.","It\u2019s been a tsunami. And I\u2019ve been riding it on a mercury surfboard.","We\u2019re on a rocket ship to the moon some nights.","I don\u2019t understand what I did wrong except live a life that everyone is jealous of.","Duh, WINNING.","Park your nonsense.","Don\u2019t live in the middle.","Adonis DNA.","We\u2019re shaking the tree. We\u2019re shaking all the trees.","I am grandiose. Because I live a grandiose life.","Celebrate this movement.","Get a job, anyone?","You can\u2019t process me with a normal brain.","I\u2019ve got tiger blood and Adonis DNA.","You\u2019ve been given magic. You\u2019ve been given gold.","Bi-polar? The Earth is bi-polar.","Damn, I didn\u2019t take care of myself. Again.","I just want to hug him and rub his head.","I\u2019m an exciting client.","What\u2019s not to love?","I\u2019m alive. Bring it.","Look at these sad trolls.","I\u2019m a peaceful man with bad intentions.","Sorry Middle America.","Who wants to deal with all the small talk?","Really dude? Really?","The last time I used? What do you mean? I used my toaster this morning.","Everything. Next question.","Can I have one part of my life that isn\u2019t TMZ\u2019d up the butt?","We need his wisdom and his *****in\u2019-ness.","Work fuels the soul.","Winning. Everyday.","Add some gold.","Change your brain.","People can\u2019t figure me out. They can\u2019t process me. I don\u2019t expect them to.","They can\u2019t hang with me. Their bones would melt like wax.","I\u2019m not \u2018aw shucks\u2019. Because I\u2019m gnarly.","Got to dismiss these clowns.","I\u2019m on a quest to claim absolute victory on every front.","Teamwork. Bang.","The wildfires are spreading. The meek are scattering.","They hate themselves first.","Biggest star in the world.","I\u2019m living inside the truth. And the truth doesn\u2019t change.","He has no salt in his soul.","C\u2019mon. The guy wears corduroys.","I honorably pass that torch to these young geniuses.","Change the channel. I dare you.","I\u2019ve been blessed with a new brain.","It\u2019s about winning. Sorry.","*****in\u2019 focus.","Get back in the game dude.","Get the cancer out of the mix.","Gnarly you are not.","Of course you\u2019re gnarly. You\u2019re talking to me.","Wow. That\u2019s epic.","That just flew out. That was a pretty good one.","It's a turd that opens on a tugboat.","If they want me in it, it's a smash.","No panic. No judgement.","Hope is for suckers and tools.","The people would revolt.","You can tell him one thing. I own him.","Missing a lot of good sports, people. Lots.","My passion was asleep for a long time.","I finally extracted myself from their troll hole.","They tell you to lay down your sword. Really? Wow, dude's unarmed. WHACK.","I think you've got a little more magic than you realize.","You make a choice to win, and you win.","I have to tip my hat to them.","There's a reason I've had mad success doing comedy.","Yeah I'll do a movie with you. You're awesome.","I don't forget anything, you know?","I can't pee in front of you guys.","Flinching's for amateurs.","He has no salt in his soul.","It's about winning. Sorry.","They can't really ruffle this assassin's feathers.","We form a group called the wedge.","Panicking is for amateurs and morons.","I don't believe in panicking.","They could have fleeced the sheep a thousand times, but they chose to skin it once.","It feels like the hot springs of Middle Earth are finally ready to explode outward.","It feels like the worm's turning.","It boils and it fuels you. It boils in a state that would eclipse a microwave.","Ride down the face of a tsunami and tell me you don't feel *****in'.","I\u2019m an F-18 bro."]; function randomQuote(){ var quote = document.getElementById("quote"); var rand = Math.ceil( Math.random() * (quotes.length - 1) ); quote.innerHTML = quotes[rand]; } </script> </div><!-- end wrapper --> </body> </html> I'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> 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? 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)); 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 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?
|