duanjigua5753 2016-02-21 12:03
浏览 104
已采纳

PHP ajax数据库:如何传递两个变量并在不同的选项中获取它们的数据?

(Re Post) i had going through this tutarial : PHP ajax database : how to pass two variables and get data of them in different div even one? ,but it seems not working,and i need to have 3 select works together.i choose first select option then using ajax to pass data for getting second and using the

                function showUser(strOther);

to get third data which is related to the first and second answer.all is running well but the third select which is:

               <select id="txtHint1">

doesnt show me any answer.here is my scripts:

                <script>
                   function showForum(str) {
                     if (str=="") {
                   document.getElementById("txtHint").innerHTML="";


                         return;
                      } 
               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) {

          document.getElementById("txtHint").innerHTML=xmlhttp.responseText;


             }
               }

                xmlhttp.open("GET","getuser.php?q="+str,true);
                xmlhttp.send();
                }
                </script>

                <script>
                          function showUser(strOther) {
                 if(strOther==""){
             document.getElementById("txtHint1").innerHTML="";
                return;
                      }
                        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) {

         document.getElementById("txtHint1").innerHTML=xmlhttp.responseText;

              }
              }

               xmlhttp.open("GET","getuser.php?q1="+strOther,true);
              xmlhttp.send();
              }
            </script>

this is the select options which i get the ajax data:

                 <!-- this forum will be
                 choosed to pass data to get second 
                   select to filled up-->
                 <form>
                   <!-- first select-->
                  <select name="users" onchange="showForum(this.value)">
                 <option value="">All Orgs</option>
                 <option value="1">WebStatsProject</option>
                  <option value="2">mmu</option>

                  </select>
                  </form>

this select option will be filled by the first ajax request: All Forums the third not show any data,the other two working properly:

                            <!-- third select-->
                             <select id="txtHint1">
                            <option value="All Users">All Users</option>
                            </select>
  • 写回答

1条回答 默认 最新

  • duanmengsuo9302 2016-02-21 12:08
    关注

    Because you not define strOther
    try this

     function showUser(str,strOther){
    

    and pass strOther to this function

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示