[Javascript] Javascript to change include filename
tedd
tedd at sperling.com
Thu Jan 22 07:56:49 CST 2009
At 12:35 PM -0600 1/21/09, Del Wegener wrote:
>Good Day;
>
>One of my websites currently contains the following div
>
> <div id="blendme">
> <!--#include file="pic3.txt"-->
> </div>
>My client wants to have 12 - 20 different pic_ordernn files. A
>random number generator should be use decide which file to include
>(pic1.txt, pic2.txt, pic3.txt, ..., or pic15.txt).
>
>I can write code to randomly create/select one of the filenames but
>how do I insert that filename in the above include statement?
>
>It seems to me the include is serverside and my JS is client side.
>
>Can that filename be a variable whose value is determined when the
>page is loaded?
>
>Is this a PHP job?
>
>Thanks for all your suggestions.
>
>Del
Del:
For you to use server-side includes like that, then the suffix for
your file should be ".shtml". Change it to ".php" and try this:
<div id="blendme">
<?php $n=rand(1,15); include('pic' . $n . '.txt'); ?>
</div>
If you need any further help, just ask.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
More information about the Javascript
mailing list