0

私は Oracle Application Express (Apex) を使用していますが、基本的に私の状況は次のとおりです。2 つの項目があります。1 つはテキスト フィールドで、もう 1 つは DB リンクを使用してテーブルをクエリすることによって値が取得される非表示の項目です。

ユーザーがテキスト フィールドに数値を入力すると、その数値が非表示アイテムのクエリで使用され、ユーザーが入力した数値と一致する ID を持つ行が検索されます。非表示項目の値は、その行のいずれかの列の内容に設定されます。

唯一の問題は、これはすべて 1 つのページにあり、ページを送信せずに実行する必要があるため、ユーザーがテキスト フィールドに数値を入力したときに、その数値をそのアイテムの値として保存して、その数値を使用できるようにする方法です。非表示アイテムの値を計算するクエリ?

どんな助けでも大歓迎です。

4

1 に答える 1

1

アップデート:

<!DOCTYPE html>
<html>
    <head>
        <script>
            function ajax(user_number) {
                var xmlhttp;
                // get the ID field for easy access... 
                var index =  document.getElementById("index");
                if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
                    xmlhttp = new XMLHttpRequest();
                } else {// code for IE6, IE5
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
                xmlhttp.onreadystatechange = function() {
                    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                        // here you get back a response... xmlhttp.responseText
                        // set the hidden field with new data.
                        index.value = xmlhttp.responseText;
                    }
                }
                // here you make a request to your script to check your database...
                xmlhttp.open("GET", "app/search/?number=" + user_number + '&index=' + index.value, true);
                xmlhttp.send();
            }

            function check(user_number) {
                // make some validation here...
                if (user_number.length > 3) {
                    ajax(user_number);
                } else {
                    return;
                }
            }
        </script>
    </head>
    <body>

        <p>please enter your secret number</p>
        <!-- the hidden field holding the ID -->
        <input type="hidden" id="index" name="index" value="334" />
        <!-- the search text box where user type his own NUMBER onkeyup it make a request -->
        <input type="text" id="user-number" name="user-number" onkeyup="check(this.value);"/>

    </body>
</html>
于 2012-12-12T17:31:12.717 に答える