4 like 0 dislike
774 views

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)
ID: 23134 - Available when: Unlimited - Due to: Unlimited
| 774 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 (31.4k 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)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.134.215
©2016-2023

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)
ID: 23133 - Available when: Unlimited - Due to: Unlimited
| 846 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)
ID: 23127 - Available when: Unlimited - Due to: 2017-03-23 09:30:00
| 554 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)
ID: 23132 - 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)
ID: 23130 - Available when: Unlimited - Due to: 2017-03-23 09:30:00
| 753 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)
ID: 23129 - Available when: Unlimited - Due to: Unlimited
| 837 views
14,692 questions
236,721 answers
212,938 comments
5,696 users