:: How to Build ::
- สร้างปุ่มกดขึ้นมาก่อน
- ประกาศอาเรย์ Display_Text มาเก็บข้อความทั้งหมด และ Current_Text ใช้เก็บข้อความที่แสดงอยู่
Display_Text=new Array("This is","Cool Site","Click Here!");
Current_Text=0;
- เขียนฟังก์ชั่น Active() ไว้ในส่วน <HEAD> ฟังก์ชั่นนี้เมื่อถูกรันจะเปลี่ยนข้อความตามที่มีใน Display_Text
function Active()
{
document.form1.button1.value=Display_Text[Current_Text];
++Current_Text;
if (Current_Text==Display_Text.length)
Current_Text=0;
}
- เรียกฟังก์ชั่น setInterval() ใน Onload ของ <Body> เพื่อให้ Active() รันทุกๆ 1000 ms
|