/    Sign up×
Community /Pin to ProfileBookmark

Picture of the day, dot show up int the browser

Hi …

I want to have diffrent picture every time i access the page.. Descriptions comes along, the real problem comes in the body — GO to the body…

<script type=”text/javascript”>

/* I created an array, therefore if i want to have a specific picture a specific day, This script i made for to have “links of the day”, but i hope it should work this way also with images instead */

var daylinks=new Array()

daylinks[1]=”465498.jpg”
daylinks[2]=”54654.jpg”
daylinks[3]=”sdfl.jpg”
daylinks[4]=”pokjpo.jpg”
daylinks[5]=”dsrw3.jpg”
daylinks[6]=”mäpo90.jpg”
daylinks[7]=”pouäpoiuj.jpg”
daylinks[8]=”k7yh98.jpg”
daylinks[9]=”p9087.jpg”
daylinks[10]=”p098.jpg”
daylinks[11]=”mp987.jpg”
daylinks[12]=”må098.jpg”
daylinks[13]=”m098.jpg”
daylinks[14]=”p98n7.jpg”
daylinks[15]=”mp9087.jpg”
daylinks[16]=”n987+80.jpg”
daylinks[17]=”098m09.jpg”
daylinks[18]=”76tb.jpg”
daylinks[19]=”u7btb8.jpg”
daylinks[20]=”o798y09hk87.jpg”
daylinks[21]=”i76gbo87o.jpg”
daylinks[22]=”987hp987.jpg”
daylinks[23]=”987h9jk.jpg”
daylinks[24]=”987hynp98y.jpg”
daylinks[25]=”98ynhp0uhjio.jpg”
daylinks[26]=”ijp09uå.jpg”
daylinks[27]=”jpg0ikm0i.jpg”
daylinks[28]=”09ujöp9uopiupoijk.jpg”
daylinks[29]=”g65t87i7.jpg”
daylinks[30]=”loiutrvd6.jpg”
daylinks[31]=”87hoi8uyk09iuiuupiuu.jpg”

/* Here Is Randomizer */

var slump=Math.random()
slump=slump*31

/* Correcting overflow */
if (slump>31){
slump=31
}

slump=Math.round(slump)

</script>
<body>

<!– Here when i want to put it in the src= i cant get it to work, nothing shows on the page when i view it int the browser –>

<IMG SRC=”+daylinks[slump]+” ALT=”Todays Picture” height=”Auto” width=”Auto”>

<!– note: I hope my discription is good and where the problem is, i am a Newbie –>

to post a comment
JavaScript

12 Comments(s)

Copy linkTweet thisAlerts:
@olafDec 10.2003 — while searching for javascript and random on google i found this page

on rank 3:

http://www.javascript-page.com/ranimage.html
Copy linkTweet thisAlerts:
@little_jimDec 10.2003 — It's doing this because in your IMG SRC you are giving it the text string "+daylinks[slump]+". What you need to do is have your javascript say...

"document.write("<img src="" +daylinks[slump]+"" alt="Todays Picture">");
Copy linkTweet thisAlerts:
@mofm_authorDec 10.2003 — Thanks for the answer ?

But it still doesnt show the picture.? The only diffrents is now i could see where the picture should have been shown and then it saids "undefined" ...

<img src="" +ranimage()+ "" alt="" +ranimage()+ "">
Copy linkTweet thisAlerts:
@mofm_authorDec 10.2003 — Wrong paste in iam trying diffrent approches, here comes the correct one..

SRC='""daylinks[slump]+ "" ALT="" Todays Picture ""
Copy linkTweet thisAlerts:
@PittimannDec 10.2003 — Hi!

I think, the easiest solution for you is, to give your image a name and set the src by the script, instead of document.write it.

Something like that should work for you:
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Untitled&lt;/title&gt;
&lt;script type="text/javascript"&gt;
function getPicture(){
var daylinks=new Array()
daylinks[1]="465498.jpg"
daylinks[2]="54654.jpg"
daylinks[3]="sdfl.jpg"
daylinks[4]="pokjpo.jpg"
daylinks[5]="dsrw3.jpg"
daylinks[6]="mäpo90.jpg"
daylinks[7]="pouäpoiuj.jpg"
daylinks[8]="k7yh98.jpg"
daylinks[9]="p9087.jpg"
daylinks[10]="p098.jpg"
daylinks[11]="mp987.jpg"
daylinks[12]="må098.jpg"
daylinks[13]="m098.jpg"
daylinks[14]="p98n7.jpg"
daylinks[15]="mp9087.jpg"
daylinks[16]="n987+80.jpg"
daylinks[17]="098m09.jpg"
daylinks[18]="76tb.jpg"
daylinks[19]="u7btb8.jpg"
daylinks[20]="o798y09hk87.jpg"
daylinks[21]="i76gbo87o.jpg"
daylinks[22]="987hp987.jpg"
daylinks[23]="987h9jk.jpg"
daylinks[24]="987hynp98y.jpg"
daylinks[25]="98ynhp0uhjio.jpg"
daylinks[26]="ijp09uå.jpg"
daylinks[27]="jpg0ikm0i.jpg"
daylinks[28]="09ujöp9uopiupoijk.jpg"
daylinks[29]="g65t87i7.jpg"
daylinks[30]="loiutrvd6.jpg"
daylinks[31]="87hoi8uyk09iuiuupiuu.jpg"
var slump=Math.random()
slump=slump*31
if (slump&gt;31){
slump=31
}
slump=Math.round(slump)
document.POTD.src=daylinks[slump];
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body onload="getPicture()"&gt;
&lt;IMG SRC="dummy.gif" NAME="POTD" ALT="Todays Picture"&gt;
&lt;/body&gt;
&lt;/html&gt;

Cheers - Pit
Copy linkTweet thisAlerts:
@mofm_authorDec 10.2003 — Thanks for that solution, it looks right - but it still show almost the same result - why it doesnt work for me!!

see the picture..

[upl-file uuid=890c157b-f766-4252-bd2b-d70d4e158b04 size=4kB]error.jpg[/upl-file]
Copy linkTweet thisAlerts:
@PittimannDec 10.2003 — Hi!

The .jpg files have to be in the same folder like the file with the script!

Sure, that helps...

Cheers - Pit
Copy linkTweet thisAlerts:
@mofm_authorDec 10.2003 — yes ? i have the images in the same Directory...

and if i right click and click Property i can se that i can see the path and a image file name ... im begining to think that this isnt my day..
Copy linkTweet thisAlerts:
@PittimannDec 10.2003 — Hi!

The right click and property stuff only proves, that your browser attempted to load the image from the directory, where your file with the script is situated.

If your images were there, the randomly chosen one should be displayed...

Cheers - Pit
Copy linkTweet thisAlerts:
@little_jimDec 10.2003 — It now seems that your script isn't the problem, it may be that...

[list=a]
  • [*]There is something wrong with the Jpg's, try viewing them in an image editor

  • [*]There is something weird about your browser.

  • [*]The jpg's arn't where you say they are.

    [/list=a]

    try adding a test jpg which you know is valid, and then view that in the browser.
  • Copy linkTweet thisAlerts:
    @mofm_authorDec 11.2003 — Im glad that U guys try to help me... Thanks...

    okay i.c the property only shows that the path to the image and that is correct shown, good.. But the image is still not shown.. strange

    a: the picture can be open in paint, n problem with it

    b: i hav checket it in opera and in 2 other computer at work and same thing happend there

    c: the pictures ar in tha same directory as the web page so it should work then

    ?

    So what is then wrong..
    Copy linkTweet thisAlerts:
    @mofm_authorDec 12.2003 — ?

    Now I rewrote the whole code on new page and now its working ?

    I cant see any diffrents between the codes, just happy its working ? greate

    thanks guys
    ×

    Success!

    Help @mofm_ spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.4,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...