2011-07-25 32 views
0

在我的網頁中,我使用兩個選擇框,第二個將根據在第一個選擇框中使用ajax(dojo插件)選擇的值進行填充。struts 2多個選擇框

<s:select label="Select Item" 
      name="selectitem" 
      headerKey="0" 
      headerValue="-- Please Select --" 
      list="itemList" 
      required="true" 
      onchange="javascript:show_details();"/> 


<s:url id="d_url" action="depotFill" /> 

<sx:div id="details" 
     href="%{d_url}" 
     listenTopics="show_detail" 
     formId="depotFix" 
     showLoadingText="Loading..."></sx:div>  

第二個選擇框將使用「depotFill」動作填充,並從其他頁面加載到「details」div標記。

<%@ taglib prefix="s" uri="/struts-tags"%> 

<s:select headerValue="-- Please Select --" 
      name="dest" 
      list="unitList" 
      headerKey="0"/> 

這工作正常,但現在我需要在我的網頁上有這樣的5對。這是否意味着我將不得不創建5個包含輔助選擇框的頁面?或者有什麼辦法來簡化這個?

在此先感謝。

+1

** [](http://struts.apache.org/2.2.3/docs/doubleselect.html)**? – lschin

回答

0

doubleselect將爲您做到這一點。它呈現一個選擇標記(對於第一個下拉值),每個標記包含選中時第二個下拉列表的選項的子列表。

Struts Guide - doubleselect tag ref

+0

我可以用ajax嗎?道場支持? – user759740

+0

我沒有,但我不明白爲什麼不。該標籤創建一個JavaScript函數。實施它,右鍵單擊>查看源代碼,盡情享受吧!應該能夠用AJAX – CrackerJack9

+0

更新它的數組謝謝... :) – user759740