Hey, welcome to ZBCode, the premier coding forum for ZB. Here you fill find some of the best Invisionfree and Zetaboards Codes on the network! Unfortunately, you're sorta hovering around in guest mode at the moment; why not join in on the fun? Register an account and you can start accessing the wealth of resources we have available here. Enjoy your stay at ZBCode, and remember to tell all your friends about us; the more members, the more codes available. ![]() Interested in joining? Click here. If you are already a member of ZBCode, feel free to login right here: |
| [Completed] [ZB] Quote Generator (Limited) | |
|---|---|
| Tweet Topic Started: Oct 7 2009, 12:40 PM (243 Views) | |
| thebawp | Oct 7 2009, 12:40 PM Post #1 |
![]()
|
Okay, I have searched high and low for a script that performs in the way I would like but unfortunately I have come up just a little short. This is the nearest I can find: http://javascript.internet.com/games/ask-mustafa.html I have managed to amend the code slightly to my own needs, but I still can't get it to do exactly what I would like as it requires you to type in your own question and I just want a quote to appear on click. I also know you won't amend a code without permission, so I will explain what I would like and hope someone can duplicate it for me. Basically, I want my forum members to click either a button or an image and a random quote to be produced (either below or above the button, but preferably in an inscreen pop up if that's possible). I have found scripts that suit this purpose perfectly. However, I would like to limit it so that they can only click the button/image 3 times and then any further clicks will produce a second set of random quotes (i.e. go away now, I'm tired..etc). This way they can't exhaust the random quotes without refreshing the page (if they want to do that, then fine XD). I will be adding this code into a premade webpage on my board (built with the website maker). Hopefully my explanation is clear enough, if there are any details that need clarifying then please let me know. Thanks for your time! Kirsty |
![]() |
|
| Reid | Oct 7 2009, 04:16 PM Post #2 |
![]()
What? The land of the free? Whoever told you that was your enemy.
![]()
|
Try this on your web page: There are a few things. Firstly, the button to generate another random quote must have an id of r_quote - like this: The place where the quote will be inserted should have an id of quote_o - like this: Now for the actual code editing itself... You see the piece of code that says levels? Well, those are the different levels of quote that there are. The first number is how many clicks it will take to move up a level. For example, you will be pulling quotes from first_quote (we'll get to that in a sec) as long as they haven't clicked over 3 times. Once they've clicked the 4th time, it will begin to grab quotes from the next level (in this case, second_quote) until they get over 6 clicks (since that's what the next level says.) Once they get over 6, it'll go to the next level, and so on... Now the second part of the levels is where it'll grab the quotes from. When they have less than 3 clicks (the first level) then it will pull quotes from the second part of the level. In this case, that's called first_quote. If you look down in the code you'll see where we define first_quote as some quotes. You can add more or less as needed. Then the second level draws from second_quote and then the third from third_quote and so on and so forth. If you want to add more levels, then simply add another level on the end like so: Then you have to define fifth_quote as something. For logic's sense, I'd write it right after fourth_quote, but it doesn't really matter: I realize this is a really sketchy explanation of how the code works, but you couldn't honestly expect it to be simple, could you? ![]() Tell me if you need help.
|
| The Resource Board | |
![]() |
|
| Reid | Oct 7 2009, 04:18 PM Post #3 |
![]()
What? The land of the free? Whoever told you that was your enemy.
![]()
|
Note: If you want it to be a pop-up instead of having it appear on page, change this line: to
|
| The Resource Board | |
![]() |
|
| thebawp | Oct 7 2009, 06:13 PM Post #4 |
![]()
|
Absolutely awesome. You've actually made this as flexible as I would have liked though I hardly dare ask for the extra stuff! I think the only problem I had was remembering to put " " around a quote that had an apostrophe in it. Stunning, thank you so much. =) Actually, is it possible to use this code to redirect someone if they click so many times? Could be a fun little easter egg! So, for example, when they reach level 4, instead of receiving a message, they are sent to a different page? Edited by thebawp, Oct 7 2009, 06:14 PM.
|
![]() |
|
| Reid | Oct 7 2009, 06:27 PM Post #5 |
![]()
What? The land of the free? Whoever told you that was your enemy.
![]()
|
Try this instead, then: Instead of putting first_quote or something, just put a url there instead. Be sure it's a full, good URL - with the http:// and everything. Edit: Fixed a bug Edit 2: Cleaned it up a bit Edited by Reid, Oct 7 2009, 06:35 PM.
|
| The Resource Board | |
![]() |
|
| thebawp | Oct 8 2009, 01:54 AM Post #6 |
![]()
|
Well, that's just working perfectly by the looks of things! Thank you so much! I think this can be closed now. Thanks again! |
![]() |
|
| Reid | Oct 8 2009, 03:59 PM Post #7 |
![]()
What? The land of the free? Whoever told you that was your enemy.
![]()
|
You're welcome. See? We can read thoughts too. ;) Your request has been completed, and we're moving it to the correct forum. We hope it works for you; if it doesn't, feel free to post another request topic in the requests forum. Just remember: read the rules first! Thanks, The ZBCode Staff |
| The Resource Board | |
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| « Previous Topic · Completed Requests · Next Topic » |
















2:27 PM Jul 11