如何在此脚本上同时传递多个变量

时间:2014-12-14 03:39:36

标签: javascript asp-classic

现在我已经改变了#34;?"到"&"已经并且还添加了一个变量到" onChange =" showBillbyMonth(this.value,selectedYr)"但它仍然不起作用。

我找到了适合我的脚本。但是我需要同时传递2个变量..我已经尝试但没有工作。我对javascript的了解非常有限,所以请帮帮我..谢谢

用于传递一个变量的脚本

<script type="text/javascript">
function showBillbyMonth(str)
{
var xmlhttp;
if (str=="")
  {
  document.getElementById("btxtHint").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("btxtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","billMonth_view.asp?q="+str,true);
xmlhttp.send();
}
</script>

我修改过的脚本在下面不起作用

<script type="text/javascript">
function showBillbyMonth(str,selectedYr)
{
var xmlhttp;

if (str=="")
  {
  document.getElementById("btxtHint").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("btxtHint").innerHTML=xmlhttp.responseText;
    }
  }

xmlhttp.open("GET","billMonth_view_inYear.asp?q="+str+"&selectedYr="+selectedYr,true)


xmlhttp.send();
}
</script>

我用过这个......

<form action="" > 
      <td align="right" >

         <select name="inmonth" id="inmonth" onChange="showBillbyMonth(this.value,selectedYr)">
                                        <option value="">Month</option>
                                        <option value="1">January</option>
                                        <option value="2">February</option>
                                        <option value="3">March</option>
                                        <option value="4">April</option>
                                        <option value="5">May</option>
                                        <option value="6">June</option>
                                        <option value="7">July</option>
                                        <option value="8">August</option>
                                        <option value="9">September</option>
                                        <option value="10">October</option>
                                        <option value="11">November</option>
                                        <option value="12">December</option>
         </select>                                                                                                                                                                           
        </td>       
</form>           

脚本将在页面下方打开..&#34; billMonth_view_inYear.asp&#34;

qbill_month = request.querystring("q")
current_year = request.querystring("selectedYr")

继续使用sql commmand..somthing like this ..

sql = "SELECT tbl_bill_total.cust_id, Sum(tbl_bill_total.bill_total) AS sum_bill_total, tbl_customer.cust_name, Month([tbl_bill_total.showndate]) AS bill_month, Year([tbl_bill_total.showndate]) AS bill_year FROM tbl_bill_total INNER JOIN tbl_customer ON tbl_bill_total.cust_id = tbl_customer.cust_id GROUP BY tbl_bill_total.cust_id, tbl_customer.cust_name, Month([tbl_bill_total.showndate]), Year([tbl_bill_total.showndate]) HAVING (((Month([tbl_bill_total.showndate]))="& qbill_month &") AND ((Year([tbl_bill_total.showndate]))="& current_year &"));"

3 个答案:

答案 0 :(得分:0)

如果网址中有多个参数,请将其与&分开,而不是??仅用于将URL路径名与参数分开。所以它应该是:

xmlhttp.open("GET","billMonth_view_inYear.asp?q="+str+"&selectedYr="+selectedYr,true);

答案 1 :(得分:0)

你需要用&amp;。

分隔两个参数

更改

xmlhttp.open("GET","billMonth_view_inYear.asp?q="+str+"?selectedYr="+selectedYr,true);

通过

xmlhttp.open("GET","billMonth_view_inYear.asp?q="+str+"&selectedYr="+selectedYr,true);

答案 2 :(得分:-1)

您没有传递showBillbyMonth()的第二个参数,那么它将如何工作?

由于