ตัวอย่าง

 



Now showing tip number: of

 

 1. Code1 ใส่ไว้ใน Tag<head> Code2 ใส่ไว้ใน Tag<body>ตรงที่ต้องการให้เฟรมปรากฏ
 2. ใน Code1 ตรง var_tip=".............."เป็นส่วนที่ใส่ข้อความที่ต้องการให้ปรากฏในเฟรม
 3. ข้อความจะมี 8 ข้อความ สามารถจะเพิ่มหรือลดได้(ให้เปลี่ยนตรงvar totalTips=8;เปลี่ยนเลขเป็นจำนวนข้อความด้วย)
 4. Code2 ตรง <textarea NAME="tipsHere" ROWS="4" COLS="45" เป็นการกำหนดขนาดเฟรมเปลี่ยนได้ตามต้องการ
Code1
<script LANGUAGE="JavaScript1.1">

<!--Cast invisibility spell here

//The Tip Machine is a tip display script that is very

//resistant to problems. Mostly because it is very

//simple. This "low tech" javaScript solution was

//written by Mark Naker (TIMELORDS ANONYMOUS) for

//NERO Colorado. It can be used freely as long as

//this comment block remains.

// Tip Machine version 1.0

//Copyright TIMELORDS ANONYMOUS 1997

function chngNext(){

document.tipMachine.shownext.value = "Y"

tipMach();

}

function chngPrev(){

document.tipMachine.showprev.value = "Y"

tipMach();

}

function tipMach(){

var totalTips = 8; //set total number of tips here

if ((document.tipMachine.shownext.value == "Y") &&

(document.tipMachine.showprev.value == "N")){

var tipShow = (parseInt(document.tipMachine.nowShowing.value) +1);

if (tipShow > totalTips){

var tipShow = 1;}

}

if ((document.tipMachine.showprev.value == "Y") &&

(document.tipMachine.shownext.value == "N")){

var tipShow = (parseInt(document.tipMachine.nowShowing.value) - 1);

if (tipShow < 1){

var tipShow = totalTips;}

}

if ((document.tipMachine.showprev.value == "N") &&

(document.tipMachine.shownext.value == "N")){

var tipShow = (Math.random() * totalTips);

var tipShow = Math.ceil(tipShow);}

//additional tips can be added here just follow the pattern

//remember to use single quotes in the tip text or else bad

//things will happen. Do it this way "text 'more text' text"

if (tipShow == 1) {

var _tip = "Paste this code into your page and jazz up the formatting however you want. Then put in your tips";

}

if (tipShow == 2) {

var _tip = "The script can handle a virtually unlimited number of tips.";

}

if (tipShow == 3) {

var _tip = "The best part about this script is it doesnt reload the page.";

}

if (tipShow == 4) {

var _tip = "Sometimes the low tech 'it doesnt break' solution is the best.";

}

if (tipShow == 5) {

var _tip = "Put your tips here.";

}

if (tipShow == 6) {

var _tip = "Isn't Javascript cool!.";

}

if (tipShow == 7) {

var _tip = "You dont have to put tips here you could put any text you want to display like this in here.";

}

if (tipShow == 8) {

var _tip = "Another TIP you can choose to set";

}

document.tipMachine.tipsHere.value = _tip;

document.tipMachine.nowShowing.value = tipShow;

document.tipMachine.ofTotal.value = totalTips;

document.tipMachine.shownext.value = "N";

document.tipMachine.showprev.value = "N";

}

//Dispell invisibility here-->

</script>

 

Code
<form NAME="tipMachine" METHOD="post">

<input type="hidden" name="shownext" value="N"><input type="hidden" name="showprev"

value="N"><div align="center"><center><p style="margin-right: 0"><textarea NAME="tipsHere" ROWS="4" COLS="45"

WRAP="virtual" onFocus="this.blur();">Tip Machine</textarea><br>

<input TYPE="button" VALUE="RANDOM" onClick="tipMach();"> <input TYPE="button"

VALUE="NEXT" onClick="chngNext();"><input TYPE="button" VALUE="PREV" onClick="chngPrev();">

<br>

Now showing tip number: <input TYPE="text" SIZE="3" NAME="nowShowing" value="1"

onFocus="this.blur();"> of <input TYPE="text" SIZE="3" NAME="ofTotal"

onFocus="this.blur();"><br>

</p>

</center></div>

</form>

 

[ Home ]  [ Chatroom ]  [ Board 1]  [Board 2 ]  [ Book ]  [ Sourcecode ]  [ Free ]  [ Servicesite ]  [ Link ]

1