用jquery生成二级菜单
[javascript]<pre name="code" class="html"></pre>页面中的函数
<pre></pre>
<pre name="code" class="javascript"> function querySub(id,sid/*选中的项*/){</pre><pre name="code" class="javascript"> $.post('${path}/page/article/querySubChannelArticle.action',
{'channelId':id},function(data){
$('select[name="article.subChannel.subId"] option[value!=""]').remove();
var jsonObj = data;
for ( var i = 0; i < jsonObj.length; i++) {
var $option = $('<option>');
$option.attr('value',jsonObj[i].subId);
if(jsonObj[i].subId === sid){
$option.attr('selected',true);
}
$option.text(jsonObj[i].subName);
$('select[name="article.subChannel.subId"]').append($option);
}
});
}
$(function(){
querySub(<s:property value='article.subChannel.channel.channelId'/>,<s:property value='article.subChannel.subId'/>);
});
</pre><br>
<p>页面代码:</p>
<p></p><pre name="code" class="javascript"><pre name="code" class="html"> <tr>
<th>一级栏目</th>
<td valign="middle">
<s:select id='_channel' list="channelList" listKey="channelId"
listValue="channelName"
key="article.subChannel.channel.channelId"
onchange="querySub(this.value)"></s:select>
</td>
</tr>
<tr>
<th>二级栏目</th>
<td valign="middle">
<s:select name='article.subChannel.subId' list="{}" headerKey="" headerValue="-请选择-"></s:select>
<!--<s:property value="article.subChannel.subName"/>
--></td>
</tr>
</pre><p></p>
<div><br>
</div>
<pre></pre>
<br>
<p></p>
<p>服务器端</p>
<p>服务器端</p>
<p></p><pre name="code" class="java"> public String querySubChannelArticle(){
HttpServletResponse response=getResponse();
HttpServletRequest request=getRequest();
response.setContentType("application/json; charset=UTF-8");
PrintWriter out =null;
try {
out = response.getWriter();
List<Map<String,Object>> list = new LinkedList<Map<String,Object>>();
if(channelId!=null && !channelId.equals("")){ 
补充:web前端 , JavaScript ,