Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在SQL查询中使用文本字段值而不提交_Javascript_Sql_Oracle_Oracle Apex - Fatal编程技术网

Javascript 在SQL查询中使用文本字段值而不提交

Javascript 在SQL查询中使用文本字段值而不提交,javascript,sql,oracle,oracle-apex,Javascript,Sql,Oracle,Oracle Apex,我使用的是Oracle Application Express(Apex),基本上我的情况是:我有两个项,一个是文本字段,另一个是隐藏项,其值通过使用DB链接查询表来检索 用户应该在文本字段中输入一个数字,然后在查询隐藏项时使用该数字来查找ID与用户输入的数字匹配的行。然后将隐藏项的值设置为该行某列的内容 唯一的问题是,这都在一个页面上,必须在不提交页面的情况下完成,因此当用户在文本字段中输入数字时,我如何将该数字存储为该项的值,以便在查询中使用它来计算隐藏项的值 任何帮助都将不胜感激。更新:

我使用的是Oracle Application Express(Apex),基本上我的情况是:我有两个项,一个是文本字段,另一个是隐藏项,其值通过使用DB链接查询表来检索

用户应该在文本字段中输入一个数字,然后在查询隐藏项时使用该数字来查找ID与用户输入的数字匹配的行。然后将隐藏项的值设置为该行某列的内容

唯一的问题是,这都在一个页面上,必须在不提交页面的情况下完成,因此当用户在文本字段中输入数字时,我如何将该数字存储为该项的值,以便在查询中使用它来计算隐藏项的值


任何帮助都将不胜感激。

更新:

<!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>

函数ajax(用户号){
var-xmlhttp;
//获取ID字段以便于访问。。。
var index=document.getElementById(“索引”);
if(window.XMLHttpRequest){//IE7+、Firefox、Chrome、Opera、Safari的代码
xmlhttp=新的XMLHttpRequest();
}else{//IE6、IE5的代码
xmlhttp=新的ActiveXObject(“Microsoft.xmlhttp”);
}
xmlhttp.onreadystatechange=函数(){
if(xmlhttp.readyState==4&&xmlhttp.status==200){
//这里返回一个响应…xmlhttp.responseText
//使用新数据设置隐藏字段。
index.value=xmlhttp.responseText;
}
}
//在这里,您向脚本发出检查数据库的请求。。。
xmlhttp.open(“GET”、“app/search/?number=“+user_number+”&index=”+index.value,true);
xmlhttp.send();
}
功能检查(用户号){
//在这里做一些验证。。。
如果(用户号长度>3){
ajax(用户号);
}否则{
返回;
}
}
请输入您的密码


什么版本的Apex?在Apex 4.0以后的版本中,动态操作可以做到这一点。@JeffreyKemp Apex 4.2,我来看看动态操作,如果您知道如何使用动态操作,请告诉我,谢谢您创建了一个动态操作,在文本字段项上的更改事件中触发。真正的操作是PL/SQL块,它可以检索隐藏项的值。