Thursday, August 16

Friend Links V2

對程式做了小變動。

主要變動如下:


  1. 加入<br/>
    function initialFriendType(f) {

    f.friendType.length = typeLength;

    for (var i = 0; i < typeLength; i ++ ) {

    f.friendType.options[i].value = i;

    f.friendType.options[i].text = friendType[i];

    }

    f.friendType.options[0].selected = true;

    }



  2. 使用HTML繪出兩個下拉式選單,在繪出空的下拉式選單之後,透過呼叫initialFriendType方法,將下拉式選單的值填入

    <form name="ff">好友分類

    <select onchange="changeFriend(this.value)" name="friendType">

    <option/>請選擇

    </select>
    好友暱稱

    <select onchange="goToAddress(this.value)" name="friendName">

    <option/>請選擇

    </select>

    </form>

    <script language="javascript">

    initialFriendType(document.ff);

    </script>



  3. 增加變數ty,用以指定陣列元素,日後可依個人喜好,配合好友分類更改排序。

    ty = 1;//配合好友分類陣列值。

    friend[ty].push(new Person("雅虎", "http://www.kimo.com.tw"));





如此一來,原程式碼定義好友分類的陣列即可派上用場,日後儘管加上類別即可,而不必再更動HTML碼。




Creative Commons License


This work is licensed under a
Creative Commons Attribution-Share Alike 3.0 License.

No comments: