[jQuery] Re: Randomly insert one of a pre-defined HTML extracts?

2007-06-28 Thread zarino
Aahh, fair enough. I'm having to design this for somebody else to maintain (someone with little coding knowledge) and I guessed just having one file would be easier than having two. I'll ask their opinion. But thank you for everything. :-D ~ Zarino On Jun 27, 11:38 pm, Scott Sauyet <[EMAIL PR

[jQuery] Re: Randomly insert one of a pre-defined HTML extracts?

2007-06-28 Thread zarino
Ooh, Scott, I'm so sorry, I've just realised a problem. Since the path to the 'facts' directory is relative, it only works for 'parent' HTML files on the one level. I have a homepage at the root level (eg: keep/default.htm), and then various other pages one level further in (eg: keep/why/default.

[jQuery] Re: Randomly insert one of a pre-defined HTML extracts?

2007-06-27 Thread Scott Sauyet
zarino wrote: Excellent! That was it. It all works brilliantly now. :-D As a side-note: Am I being really picky here, or could the contents of facts.js and custom.js be combined into one file? Seems a shame to have a whole separate javascript file containing just one line of code. That would

[jQuery] Re: Randomly insert one of a pre-defined HTML extracts?

2007-06-27 Thread zarino
Excellent! That was it. It all works brilliantly now. :-D As a side-note: Am I being really picky here, or could the contents of facts.js and custom.js be combined into one file? Seems a shame to have a whole separate javascript file containing just one line of code. Thanks so much. ~ Zarino

[jQuery] Re: Randomly insert one of a pre-defined HTML extracts?

2007-06-27 Thread Scott Sauyet
zarino wrote: Hm... I've made the path relative to the HTML file, but it still doesn't work. My fault. Try: var fact = facts[Math.floor(facts.length * Math.random())]; not var fact = facts[Math.floor(facts.size * Math.random())]; -- Scott

[jQuery] Re: Randomly insert one of a pre-defined HTML extracts?

2007-06-27 Thread zarino
Hm... I've made the path relative to the HTML file, but it still doesn't work. You can now find all of the files here - http://zarino.zappia.co.uk/keep/ ...or for quick reference: - http://zarino.zappia.co.uk/keep/default.html - http://zarino.zappia.co.uk/keep/scr/files.js - http://zar

[jQuery] Re: Randomly insert one of a pre-defined HTML extracts?

2007-06-27 Thread Scott Sauyet
zarino wrote: How come the javascript governing which file-name to choose isn't working? Also, does the path in the jQuery .load event have to be relative to that javascript file, or the 'parent' html file? The path should be relative to the HTML page, not the Javascript. If that doesn't work

[jQuery] Re: Randomly insert one of a pre-defined HTML extracts?

2007-06-27 Thread zarino
Wow, Scott, that's thorough! The third method seems the most plausible. I've tried to implement it, but the fact snippets don't appear in the 'factholder'. Safari tells me there's an error loading the page, and I see that it's tried to load the file "website/facts/undefined.html" (instead of "web

[jQuery] Re: Randomly insert one of a pre-defined HTML extracts?

2007-06-27 Thread Scott Sauyet
zarino wrote: Server-side coding would be nice, but it's not PHP-enabled, and I think the only method would through ASP which I, frankly, haven't the foggiest clue about! For the time it'll take to download the relatively small number of 'facts', it shouldn't be a problem. Wasted bandwidth! T

[jQuery] Re: Randomly insert one of a pre-defined HTML extracts?

2007-06-27 Thread zarino
Thanks guys! Server-side coding would be nice, but it's not PHP-enabled, and I think the only method would through ASP which I, frankly, haven't the foggiest clue about! For the time it'll take to download the relatively small number of 'facts', it shouldn't be a problem. I take it, using your c

[jQuery] Re: Randomly insert one of a pre-defined HTML extracts?

2007-06-26 Thread Glen Lipka
I agree. I was stretching his original intent. :) Glen On 6/26/07, Scott Sauyet <[EMAIL PROTECTED]> wrote: Glen Lipka wrote: > Scott, I can think of a couple reasons for this. > Let's say you want to scroll some facts or quotes or customer testamonials across the screen, but you also want to

[jQuery] Re: Randomly insert one of a pre-defined HTML extracts?

2007-06-26 Thread Scott Sauyet
Glen Lipka wrote: Scott, I can think of a couple reasons for this. Let's say you want to scroll some facts or quotes or customer testamonials across the screen, but you also want to start at a random one. That sort of thing. Or scrolling images. Oh, I can see plenty of reasons for choosin

[jQuery] Re: Randomly insert one of a pre-defined HTML extracts?

2007-06-26 Thread Glen Lipka
psuedo code: var totalDivLength = $("div").length; var randomnumber = Math.floor(Math.random()*totalDivLength) $("div")[randomnumber].show() Scott, I can think of a couple reasons for this. Let's say you want to scroll some facts or quotes or customer testamonials across the screen, but you also

[jQuery] Re: Randomly insert one of a pre-defined HTML extracts?

2007-06-26 Thread Scott Sauyet
zarino wrote: Is it possible to use jQuery to choose an extract of HTML (for example one div out of a possible ten to choose from) and insert it in a page? It's doable. Check out http://tinyurl.com/fspg5 for information on using Javascript's implementation of a "random()" function. But thi