28 December 2007

Ignore the button for now...

I'm attempting to make it so that you can get a new random quote by pushing a button, a la John's... At the moment, I've succeeded in creating a button that does nothing. So click on it if you want, just don't expect anything to happen.

21 comments:

John said...

If you want, I can tell you how I did it.

Qalmlea said...

Eh, I'll play around some more first. Since I'm not sure we used the same script for the random quotes, it may not work quite the same way anyway.

John said...

Do you have an array of quotes that is randomly selected?

If so then it will work.

Qalmlea said...

Yeah, okay. I think I'm stuck.

John said...
This comment has been removed by the author.
Qalmlea said...

LOL. I got it so that the button will take you to a separate page and display a random quote on a white background... ^/^ Progress. Sort of.

John said...

sorry I goofed.

make the following changes:

document.write(quotes[index]);

becomes (replace curly braces with angle brackets, keep the quotes)

document.write("{p id='qt'}" + quotes[index] + "{/p}");

add the following above the {/script}:

function getQuote()
{
var rand = Math.round( (quote.length-1) * Math.random() ) ;
document.getElementById("qt").innerHTML=quotes[rand];
}

the button you have defined should work as is

John said...

above the {/script} means above the //--}, too

John said...

adding the paragraph tag with id allows getElementById() to find it.

the .innerHTML=quotes[rand] replaces the text.

Qalmlea said...

*sighs* Still a no go. Not sure why, but it's giving me a headache so I'm giving up for the moment and reverting. Thanks anyway.

John said...

id='qt' single quotes, because it's they're nested inside " " (when the computer sees " it assume the next on is the closing)

make sure that //--} is immediately above the {/script}

John said...

seriously change id="qt" to id='qt' and it looks like it will work.

Qalmlea said...

Okay, I've tried to do that twice now. And when I go back to check, it's been changed to "qt" again.

John said...

the {!-- above the function definition shold be deleted, too.

John said...

wierd.

John said...

those double quotes are the only problem I can see. they are what's keeping it from working. I donn't know why they get changed back.

Qalmlea said...

Very. And frustrating. So for now it's reverted.

John said...

I got it.

go here and copy the entire thing into your random quote widget. I know it works, because I tested it on my blog.

John said...

as I was testing the ReAquire button, I saw this quote:

"The perfect blossom is a rare thing. You could spend your life looking for one, and it would not be a wasted life. ~The Last Samurai"

Do you have the followup statement where he says:

"I was wrong, they're all perfect."

Qalmlea said...

Yay! That did it! THANKS!

And, no, I don't have the follow-up in there yet. I was watching it and added at least one more recently, but didn't get to that scene. It may be put in there eventually.

John said...

Cool. You're welcome. I'm gonna delete that page from my Google Docs account.