/    Sign up×
Community /Pin to ProfileBookmark

Hi,

i was wondering if anyone could help me.

i have two bits of code

<html>
<body>
<script type=”text/javascript”>

number1 = parseInt(Math.random() * 6+1);
number2 = parseInt(Math.random() *
6+1);
number3 = parseInt(Math.random() * 6+1);
number4 = parseInt(Math.random() *
6+1);

document.write(number1 + “” + number2 + “” + number3 + “” + number4);

document.write(‘<img src=”die’+ number1 +’.bmp”>’);
document.write(” “);
document.write(‘<img src=”die’+ number2 +’.bmp”>’);
document.write(” “);
document.write(‘<img src=”die’+ number3 +’.bmp”>’);
document.write(” “);
document.write(‘<img src=”die’+ number4 +’.bmp”>’);

</script>
</body>
</html>

This displays 4 random die images i have saved in file

an this is the 2nd one

<html>

<body>
<script type=”text/javascript”>

function nextroll(){
number1 = parseInt(Math.random() * 6+1);
number2 = parseInt(Math.random() *
6+1);
number3 = parseInt(Math.random() * 6+1);
number4 = parseInt(Math.random() *
6+1);

document.Score.display.value+=(number1 + “” + number2 + “” + number3 + “” + number4)+”n”;

}

document.write(‘<img src=”die’+ number1 +’.bmp”>’);
document.write(” “);
document.write(‘<img src=”die’+ number2 +’.bmp”>’);
document.write(” “);
document.write(‘<img src=”die’+ number3 +’.bmp”>’);
document.write(” “);
document.write(‘<img src=”die’+ number4 +’.bmp”>’);

</script>

<form name=”Score”>
<center>
<input type=”button” value=”roll” onclick=nextroll()>
<input type=”reset” value=”reset”>
<textarea name=”display” rows=”20″ cols=”40″ readonly></textarea>

</form>

</body>

</html>

as you can see in the 2nd one i want a button that on roll displays everything, and puts it into a text box

it does that, but doesnt even display the image

ive even tried making the function cover that action too

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@pj59Dec 09.2004 — Hello!

Something like this will do the job:[code=php]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
num=new Array();
function nextroll(){
num[0] = parseInt(Math.random() * 6+1);
num[1] = parseInt(Math.random() * 6+1);
num[2] = parseInt(Math.random() * 6+1);
num[3] = parseInt(Math.random() * 6+1);
document.Score.display.value+=(num[0] + "" + num[1] + "" + num[2] + "" + num[3])+"n";
for (var i=0;i<4;i++){
document.getElementById('img'+i).src="die"+ num[i]+".bmp";
document.getElementById('img'+i).title="die"+ num[i];
}
}
</script>
</head>
<body>
<img src="whatever.bmp" id="img0" border=0>
<img src="whatever.bmp" id="img1" border=0>
<img src="whatever.bmp" id="img2" border=0>
<img src="whatever.bmp" id="img3" border=0>
<form name="Score">
<input type="button" value="roll" onclick=nextroll()>
<input type="reset" value="reset">
<textarea name="display" rows="20" cols="40" readonly></textarea>
</form>
</body>
</html>[/code]
Copy linkTweet thisAlerts:
@jonnyhealdauthorDec 09.2004 — you really are the man!
Copy linkTweet thisAlerts:
@jonnyhealdauthorDec 09.2004 — but whats the whatever.bmp all about?
Copy linkTweet thisAlerts:
@pj59Dec 09.2004 — but whats the whatever.bmp all about?[/QUOTE]Nothing - ?

You could use "die6.bmp" instead if you want to display that one or whatever image.
Copy linkTweet thisAlerts:
@jbotDec 09.2004 — looks like [URL=http://www.codingforums.com/showthread.php?t=48694]homework[/URL] ?
Copy linkTweet thisAlerts:
@jonnyhealdauthorDec 09.2004 — [i]Originally posted by jbot [/i]

[B]looks like [URL=http://www.codingforums.com/showthread.php?t=48694]homework[/URL] ? [/B][/QUOTE]



seing which forum was better :p

you win!
Copy linkTweet thisAlerts:
@pj59Dec 09.2004 — Hey jbot!looks like homework [/QUOTE]If so, it should be close to a solution now. ?
Copy linkTweet thisAlerts:
@jbotDec 09.2004 — [i]Originally posted by pj59 [/i]

[B]it should be close to a solution now[/B][/QUOTE]


well, given that i posted a link to here at Coding Forums, I think it only right that both homeworkers share the knowledge, that way they can both be found out in equal measure LOL
Copy linkTweet thisAlerts:
@pj59Dec 09.2004 — Right! ?
Copy linkTweet thisAlerts:
@Willy_DuittDec 09.2004 — [i]Originally posted by jonnyheald [/i]

[B]seing which forum was better :p



you win! [/B]
[/QUOTE]


More like a selfish cross-poster with no respect for peoples time...

No worries [i]grasshopper[/i]... You will soon learn this practice will work against you rather than for you... Once knowledegable people able to answer your questions realize you are cross-posting, they will ignore your questions...

Have many nice days;

.....Willy
×

Success!

Help @jonnyheald 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

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