asp code

我想問下用咩code可以寫到以下既野

1.當我改左一個text field or select field 入面既野

另一個select field入面既option會改變?

例如變成第一個text field or select field入面既野

2.點先可以tick左一個radio button 佢就唔比人入野落個text field

tick另一個就比佢入?

3. 點先可以唔駛submit就check到一個text field入面有冇野而且彈個警告出黎?

以上既情況我係想唔駛submit既情況下進行

即係好似yahoo知識問問題果時下面果個問題分類咁

更新:

仲有d想問

條題目嚮http://hk.knowledge.yahoo.com/question/?qid=700704...

都係40分

更新 2:

haha 因為我對jave script識既野仲皮毛過vb,所以如果有多d例子我會好感激~

2 個解答

評分
  • 1 十年前
    最愛解答

    (1)

    The javascript section

    var options0 = new Array('A', 'B', 'C');

    var options1 = new Array('D', 'E', 'F');

    function changeOptions(index)

    {

    // remove option list in select

    var select1 = document.getElementById("Select1");

    var size = select1.length;

    for (var i = size-1; i >= 0; i--)

    select1.remove(i);

    // populate option list

    if (index == 0) {

    size = options0.length;

    for (var i = 0; i < size; i++)

    addItem(select1, options0[i]);

    }

    else if (index == 1) {

    size = options1.length

    for (var i = 0; i < size; i++)

    addItem(select1, options1[i]);

    }

    }

    function addItem(select1, val)

    {

    var oOption = new Option(val, val);

    select1.options.add(oOption);

    }

    function checkField()

    {

    var field1 = document.getElementById("Field1");

    if (!field1.value.length) {

    alert('Field1 is blank.');

    return false;

    }

    else

    return true;

    }

    The html section

    <input type="select" id="Select2" name="Select2" onchange="changeOptions(this.selectedIndex)" ]

    <option ]One

    <options ]Two

    <input type="select" id="Select1" name="Select1" ]

    (2)

    <input type="radio" name="Radio1" onclick="this.form.Field1.disabled = true" ]

    <input type="radio" name="Radio1" onclick="this.form.Field1.disabled = false" ]

    <input type="text" id="Field1" name="Field1" ]

    (3)

    <input type="submit" onclick="return checkField()" ]

    Replace ] closing tag >

  • 阿一
    Lv 7
    1 十年前

    你都識講係唔駛submit o既情況下進行, 用javascript啦

    睇你問得呢o的o野都知你識寫program, 唔駛俾source code你啦

    大致idea係用onChange event同disabled property

    下面兩個url有晒解釋同example

    http://www.w3schools.com/jsref/jsref_onchange.asp

    http://www.quirksmode.org/js/disabled.html

還有問題嗎?立即提問即可得到解答。