php程式問題,有關動態下拉選單(已補上圖片)

Home Home
引用 | 編輯 chris710908
2008-09-21 20:03
樓主
推文 x0
小弟在開發一個系統php+mysql.目前只剩一下一個問題,問題測試頁面如下

http://www.fashion.ntut.edu.tw/mio/test.php

上方表單為銷售資料上傳用,預設報告數量(Report Number)為1,就是上傳一筆資料,
而在Channel Type跟store name中我是使用二層動態下拉選單,store name會依據Channel Type不同而改變,會篩選出資料

問題在於當我選擇將報告數量選擇為2以上,就是上傳多筆紀錄的時候(上傳多筆我用迴圈達成),二階動態選單的功能就失效了?只有第一筆報告正常

report no.2..等表單的動態選單都失效....如下圖所示






動態選單我是利用DW的mxp做的

我的動態選單是當下拉class1選單時會將其分類的廠商名稱動態過濾到c_name下拉選單中,
首先class1的程式碼如下,當下拉選單改變時觸發FilterAndPopulateSubList()

複製程式
<select name="class1[]" id="class1" onChange="WA_FilterAndPopulateSubList(c_name2_WAJA,MM_findObj('class1'),MM_findObj('C_name'),1,0,false,':')">
<option value="" <?php if (!(strcmp("", ((isset($_POST["class1"]))?$_POST["class1"]:"")))) {echo "selected=\"selected\"";} ?>>-Channel Type-</option>

FilterAndPopulateSubList()與MM_findObj()如下

複製程式
function WA_FilterAndPopulateSubList(thearray,sourceselect,targetselect,leaveval,bottomleave,usesource,delimiter)     {
  if (bottomleave > 0)     {
    leaveArray = new Array(bottomleave);
    if (targetselect.options.length >= bottomleave)     {
      for (var m=0; m<bottomleave; m++)     {
        leavetext = targetselect.options[(targetselect.options.length - bottomleave + m)].text;
        leavevalue  = targetselect.options[(targetselect.options.length - bottomleave + m)].value;
        leaveArray[m] = new Array(leavevalue,leavetext);
      }
    }
    else     {
      for (var m=0; m<bottomleave; m++)     {
        leavetext = "";
        leavevalue  = "";
        leaveArray[m] = new Array(leavevalue,leavetext);
      }
    }
  }  
  startid = WA_UnloadList(targetselect,leaveval,0);
  mainids = new Array();
  if (usesource)    maintext = new Array();
  for (var j=0; j<sourceselect.options.length; j++)     {
    if (sourceselect.options[j].selected)     {
      mainids[mainids.length] = sourceselect.options[j].value;
      if (usesource)     maintext[maintext.length] = sourceselect.options[j].text + delimiter;
    }
  }
  for (var i=0; i<thearray.length; i++)     {
    goodid = false;
    for (var h=0; h<mainids.length; h++)     {
      if (thearray[i][0] == mainids[h])     {
        goodid = true;
        break;
      }
    }
    if (goodid)     {
      theBox = targetselect;
      theLength = parseInt(theBox.options.length);
      theServices = thearray[i].length + startid;
      var l=1;
      for (var k=startid; k<theServices; k++)     {
        if (l == thearray[i].length)     break;
        theBox.options[k] = new Option();
        theBox.options[k].value = thearray[i][l][0];
        if (usesource)     theBox.options[k].text = maintext[h] + WA_ClientSideReplace(thearray[i][l][1],"|WA|","'");
        else               theBox.options[k].text = WA_ClientSideReplace(thearray[i][l][1],"|WA|","'");
        l++;
      }
      startid = k;
    }
  }
  if (bottomleave > 0)     {
    for (var n=0; n<leaveArray.length; n++)     {
      targetselect.options[startid+n] = new Option();
      targetselect.options[startid+n].value = leaveArray[n][0];
      targetselect.options[startid+n].text  = leaveArray[n][1];
    }
  }
  for (var l=0; l < targetselect.options.length; l++)    {
    targetselect.options[l].selected = false;
  }
  if (targetselect.options.length > 0)     {
    targetselect.options[0].selected = true;
  }
}


複製程式
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


已解決

獻花 x0
引用 | 編輯 andyz
2008-09-21 23:40
1樓
  
懶得看程式
來點圖吧

獻花 x0
引用 | 編輯 andyz
2008-09-23 04:14
2樓
  
今天有研究一下
因該是class name的問題

如果你會用AJAX來寫的話
因該會比較好寫

獻花 x0
引用 | 編輯 chris710908
2008-09-24 12:13
3樓
  
感謝版大.我已經有利用jquery解決問題了

獻花 x0