หน้าแรก

ใบกิจกรรมการเขียนโปรแกรมคอมพิวเตอร์ ภาษา HTMLและ Java Script

 1.ให้นักเรียนเขียนโปรแกรมภาษา java script ต่อไปนี้ลงในโปรแกรม Notepad และบันทึก

ผลการทำงานของโปรแกรม


<html> 

<head>

<script language = "JavaScript">

<!--

var  a=15;

var b="ยินดีต้อนรับ";

alert(a); 

document.write(b);

</script>

</head>

</html>
 

 เมื่อพิมพ์โปรแกรมเสร็จแล้วให้ไปที่เมนู FileàSave As ตั้งชื่อ p1.html ทำตามรูป


เมื่อบันทึกเสร็จแล้วให้เปิดไฟล์ p1.html ที่ Desktopในโปรแกรม Firefox หรือ Chrome และทำการบันทึกผลการทำงานของโปรแกรม

2. ให้นักเรียนเขียนโปรแกรมภาษา java script ต่อไปนี้ลงในโปรแกรม Notepad และบันทึกผลการทำงานของโปรแกรม (ทำการบันทึกไฟล์ชื่อ p2.html  ขั้นตอนการบันทึกเหมือนรูปข้อ1)

<html>

<head> 

<script language="JavaScript">

<!-- 

var a=15;

var b=20;

if(a>b) 

{

b=a-b;

alert(b);

document.write("a-b=",b);

}

else

{

b=a+b;

alert(b);

document.write("a+b=",b);

}

</script>

</head>

</html> 


 

3. ให้นักเรียนเขียนโปรแกรมภาษา java script ต่อไปนี้ลงในโปรแกรม Notepad และบันทึกผลการทำงานของโปรแกรม (ทำการบันทึกไฟล์ชื่อ p3.html ขั้นตอนการบันทึกเหมือนรูปข้อ 1)

<html> 

<head>

<script language="JavaScript">

<!-- 

for(a=1;a<50;a++) 

{ document.write("Count=\n",a); } 

</script>

</head>

</html> 



4.ให้นักเรียนเขียนโปรแกรมภาษา java script ต่อไปนี้ลงในโปรแกรม Notepad และบันทึกผลการทำงานของโปรแกรม (ทำการบันทึกไฟล์ชื่อ p4.html ขั้นตอนการบันทึกเหมือนรูปข้อ1)

<html>

<head>

<script language="JavaScript">

<!--

var a=1; 

while(a<50)

{

document.write("Count=",a,”<br>”);

a=a+1;

}

</script>

</head>

</html>


 

 5. ให้นักเรียนเขียนโปรแกรมภาษา java script ต่อไปนี้ลงในโปรแกรม Notepad และบันทึกผลการทำงานของโปรแกรม (ทำการบันทึกไฟล์ชื่อ p5.html ขั้นตอนการบันทึกเหมือนรูปข้อ1)

<html> 

<head>

<script language="JavaScript">

<!--

var a=1;

do {

document.write("Count=",a,”<br>”);

a=a+1;

} while(a<50)

</script>

</head>

</html>


 6. ให้นักเรียนเขียนโปรแกรมภาษา java script ต่อไปนี้ลงในโปรแกรม Notepad และบันทึกผลการทำงานของโปรแกรม (ทำการบันทึกไฟล์ชื่อ p6.html ขั้นตอนการบันทึกเหมือนรูปข้อ1)

<html>

<head>

<script language="JavaScript">

<!--

for(a=50;a>=1;a--)

{ document.write("Count=",a,”<br>”); }

</script>

</head>

</html>


7. ให้นักเรียนเขียนโปรแกรมภาษา java script ต่อไปนี้ลงในโปรแกรม Notepad และบันทึกผลการทำงานของโปรแกรม (ทำการบันทึกไฟล์ชื่อ p7.html ขั้นตอนการบันทึกเหมือนรูปข้อ1)

<html>

<head>

<script language="JavaScript">

<!--

var a=50; 

while (a>=1)

{

document.write("Count=",a,”<br>”);

a=a+5;

}

</script>

</head>

</html>



 

 ใบกิจกรรมการเขียนโปรแกรมคอมพิวเตอร์ ภาษา HTMLและ Java Script

1.โปรแกรมแม่สูตรคูณโดยรับค่าทางคีย์บอร์ด

<html>

<head>

<script language="javascript">       

<!--

  var x;

  x=prompt("Input  Multiply=");

  x=parseInt(x);                                  

  document.write("x=",x);

  document.write("<br />");

  document.write("x*1=",x*1);

  document.write("<br />");

  document.write("x*2=",x*2);

  document.write("<br />");

  document.write("x*3=",x*3);

  document.write("<br />");

  document.write("x*4=",x*4);

  document.write("<br />");

  document.write("x*5=",x*5);

  document.write("<br />");

  document.write("x*6=",x*6);

  document.write("<br />");

  document.write("x*7=",x*7);

  document.write("<br />");

  document.write("x*8=",x*8);

  document.write("<br />");

  document.write("x*9=",x*9);

  document.write("<br />");

  document.write("x*10=",x*10);

document.write("<br />");

  document.write("x*11=",x*11);

  document.write("<br />");

  document.write("x*12=",x*12);

  document.write("<br />");

</script>

</head>

</html>

ผลลัพธ์ของโปรแกรม
















2. โปรแกรมเครื่องคิดเลขโดยรับค่าผ่านทางคีย์บอร์ด

<html>

<head>

<script language="javascript">       

<!--

  var x;

  var y;

  x=prompt("Input  Number1=");

  x=parseInt(x);                                  

  alert(x);

  document.write("x=",x);

  document.write("<br />");

  y=prompt("Input  Number2=");

  y=parseInt(y);  

  alert(y);

  document.write("y=",y);

  document.write("<br />");

  document.write("x+y=",x+y);

  document.write("<br />");

  document.write("x-y=",x-y);

  document.write("<br />");

  document.write("x*y=",x*y);

  document.write("<br />");

  document.write("x/y=",x/y);

  document.write("<br />");                          

</script>

</head>

</html>

ผลลัพธ์ของโปรแกรม



 



ไม่มีความคิดเห็น:

แสดงความคิดเห็น