Alright so I was wondering how I can make a text box which will have a quotation in, and under that is a button and it says tap me and each time you click it the quote changes in the text box. How can I accomplish this? Thanks!
How about this? <html> <head> <script type="text/javascript"> var curidx; var quotes = new Array(); quotes[0] = 'This is quote 1'; quotes[1] = 'This is quote 2'; quotes[2] = 'This is quote 3'; quotes[3] = 'This is quote 4'; quotes[4] = 'This is quote 5'; window.onload = function() { curidx = Math.floor(Math.random()*5); changeQuote(); } function changeQuote() { do { var idx = Math.floor(Math.random()*5); } while (idx == curidx); document.getElementById('quote').innerHTML = quotes[idx]; curidx = idx; } </script> <style type='text/css'> * { margin: 0; padding: 0; } #quotebox { border: 1px solid #000; line-height: 25px; margin: 10px; padding: 10px; text-align: center; width: 180px; } #quotebtn { height: 26px; width: 80px; } </style> </head> <body> <div id='quotebox'> <p id='quote'></p> <button id='quotebtn' onclick='changeQuote()'>Tap Me</button> </div> </body> </html> Code (markup):
This will do basically what he wants, though he may want to have a database server side (or the like) that AJAX would be required to deal with.