4 like 0 dislike

Write a JavaScript program to display a random image (clicking on a button) from the following list.
Sample Image information :

"PIPLS width: "240", height: "160"
"PIPLS width: "320", height: "195"
"PIPLS width: "500", height: "343"

[Exercise] Essay (Open question) - asked in 2016-2 CSIEB0270 - Internet System Design and Practice by (18k points)
Available when: Unlimited - Due to: Unlimited
| 130 views
0 0
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>test 1</title>
<script>
function changePicture( )
{
var x =Math.floor((Math.random()*3)+1);
var pic1 = document.getElementById("pic1");
var text1 = document.getElementById("text1");
if(x==1)
{
pic1.src ="PIPLS
//pic1.width="240";
//pic1.height: "160" ;
}
else if(x==2)
{
pic1.src ="PIPLS
//pic1.width="320";
//pic1.height: "195" ;
}
else
{
pic1.src ="PIPLS
//pic1.width="500";
//pic1.height: "343" ;
}
text1.innerHTML += x+" " ;
}
</script>
</head>
<body>
<h2> Random picture </h2>
<img id = "pic1">
<br>
<button onclick ="changePicture( )"> click to random choose a picture
</button>
<p id = "text1"> </p>
</body>
</html>

練習的code

16 Answers

0 like 0 dislike
Hidden content!
*** ** * *** * ** * **** * ** *** * *** **** *
answered by (30k points)
0 like 0 dislike
Hidden content!
**** * * * *** * *** * ** ** * *
answered by (12 points)
0 like 0 dislike
Hidden content!
* *** ** **** **** * * * * * * * * ** * *** **
answered by (-335 points)
0 like 0 dislike
Hidden content!
*** * ** ** ** * ** * ** ** * * ** * *
answered by (-61 points)
0 like 0 dislike
Hidden content!
*** * ** * * ** *** ** ** * * * * *
answered by (-10 points)
0 like 0 dislike
Hidden content!
** *** * ** * ****** **** *** ** * *** * **
answered by (-144 points)
0 like 0 dislike
Hidden content!
* ** * * * ** ****** * * **** **** ** *** ***** * *
answered by (-144 points)
0 like 0 dislike
Hidden content!
* * **** ** ** ***** **** * ** * ** * ** * * *****
answered by (-103 points)
0 like 0 dislike
Hidden content!
* ** * *** ** * ***** * ** ***** * * * * * * **
answered by (-103 points)
0 like 0 dislike
Hidden content!
* ** ** *** ** * * * * * ** *** ******
answered by (6 points)
Get it on Google Play Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:162.158.79.71
©2016-2019

Related questions

3 like 0 dislike
17 answers
[Exercise] Essay (Open question) - asked Mar 23, 2017 in 2016-2 CSIEB0270 - Internet System Design and Practice by Shun-Po (18k points)
Available when: Unlimited - Due to: Unlimited
| 127 views
3 like 0 dislike
18 answers
[Exercise] Multichoice - asked Mar 22, 2017 in 2016-2 CSIEB0270 - Internet System Design and Practice by Shun-Po (18k points)
Available when: Unlimited - Due to: 2017-03-23 09:30:00
| 24 views
2 like 0 dislike
0 answers
[Resource] asked Mar 23, 2017 in 2016-2 CSIEB0270 - Internet System Design and Practice by Shun-Po (18k points)
Available when: Unlimited - Due to: Unlimited
| 46 views
3 like 0 dislike
18 answers
[Exercise] True/False - asked Mar 22, 2017 in 2016-2 CSIEB0270 - Internet System Design and Practice by Shun-Po (18k points)
Available when: Unlimited - Due to: 2017-03-23 09:30:00
| 37 views
2 like 0 dislike
26 answers
[Exercise] Multichoice - asked Mar 22, 2017 in 2016-2 CSIEB0270 - Internet System Design and Practice by Shun-Po (18k points)
Available when: Unlimited - Due to: Unlimited
| 40 views
9,012 questions
77,061 answers
52,721 comments
2,239 users