weixin_33720078 2012-04-03 11:01 采纳率: 0%
浏览 21

动态AJAX列表未发布

I have a dynamic drop down box which calls another PHP page. I've got it to work just how I want it.

Below is the part of the form:

<tr>
 <td> 
       <p> Select a delivery date </p>
 </td> 
 <td>
     <select name='listdate' onchange='showDelivery(this.value)'>
       <option value=''>select delivery type:</option>
       <option value='forwardorder'>Forward Order</option>
       <option value='byreturn'>By Return</option>
    </select>

  <div id='txtHint'>
    <b>Change to drop down box to display delivery date</b>
  </div>
 </td> 
</tr>

The Ajax

function showDelivery(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","getDelivery.php?q="+str,true);
  xmlhttp.send();
}

The php script


$q=$_GET["q"];

    // And create a cid object
    require_once $CID_INCLUDE_PATH . "/cid.php";
    $cid = new CHCID();

    if ($q == 'forwardorder') 
    {
    echo"<td><select 'name'='deliveryDate'/> "; 
    $listCapacityDates = $cid->ListCapacity();
    foreach($listCapacityDates as $x) {
    echo "<option value='".$x."'>".$x."</option> </select>"; 
    }
    } 

    if ($q == 'byreturn')
    {
    echo"<div id='div1'>Enter By Return Date<input type='text''name='deliveryDate' />
    </div>"; 
    } 

I know the problem, because the results from the Ajax drop downs are shown through the PHP pages when the form submits none of those values are submitted. But I'm not sure how I can even submit them? Any ideas?

  • 写回答

2条回答 默认 最新

  • weixin_33712987 2012-04-03 11:06
    关注
    echo"<td><select 'name'='deliveryDate'/> ";
    

    should be :

    echo "<td><select name='deliveryDate'/> "; 
    

    and

    echo"<div id='div1'>Enter By Return Date<input type='text''name='deliveryDate' />
    

    should be :

    echo"<div id='div1'>Enter By Return Date<input type='text' name='deliveryDate' />
    

    and:

        if ($q == 'forwardorder') 
        {
        echo"<td><select 'name'='deliveryDate'/> "; 
          $listCapacityDates = $cid->ListCapacity();
          foreach($listCapacityDates as $x) {
            echo "<option value='".$x."'>".$x."</option>"; 
            }
        echo "</select></td>";
        } 
    

    </select> should be outside foreach

    评论

报告相同问题?

悬赏问题

  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式