weixin_33737774 2015-08-18 07:42 采纳率: 0%
浏览 22

发送两个值到ajax查询

I need to send two parameter to my javascript and get the parameters in the php file how I can do it ?

My html :

<form method="post" action="testButtonSup.php">
        <p>
           Veuillez choisir le service<br />
           <input type="radio" name="service" value="ncli" id="ncli" checked ="checked" /> <label for="ncli">Ncli</label>
           <input type="radio" name="service" value="fcli" id="fcli" /> <label for="fcli">Fcli</label>
        </p>
        <p>
            <label for="client">Veuillez choisir le fournisseur :</label><br />
               <select name="client" id="client" onchange="showUser(this.value, service)">
                    <?php 
                        // echo '<option value=""/></option>';
                        while ($donnees = $reponse->fetch())
                        {               
                            echo '<option value='.$donnees['refCustomer'].'>'.$donnees['legalCompanyName'].' </option>';
                            $idClient = $donnees['refCustomer'];                                
                            //$value = $donnees['refCustomer'];                     
                        }


                        $reponse->closeCursor();
                    ?>              
               </select>
            </p>
        <p>.....

I want to send to the function showUser(this.value, service) two parameters : the id of the select and the value of the radio button "service" whic is up

My function :

function showUser(str, service) {
        if (str == "") {
            document.getElementById("txtHint").innerHTML = "";
            return;
        } else { 
            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","getTableBuffer.php?q="+str+"&service="service,true);
            xmlhttp.send();
        }
    }

I tried like this but it doesn't work.

in my php file it didn't recognize the parameter.

It works with only the id of the select.

  • 写回答

2条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 Android URL如何转成视频/音频,可行吗?
      • ¥20 SQL数据查询,子查询
      • ¥15 c++字符串分割问题
      • ¥15 关于#sql#的问题:没有用命令关闭cdc,手动把系统表开启的cdc右键删除了
      • ¥15 vue+uniapp
      • ¥15 android freedom
      • ¥15 使用自定义的类型代替内置类型可行吗
      • ¥15 关于STM32的SPI和ENDAT接口编码器通信的问题
      • ¥15 关于#pdfbox#生成的PDF文件正常,转图片中文乱码的问题,如何解决?
      • ¥15 ADS中有关DAC控件的使用问题