[Javascript]
Functions on the <pre name = "code" class = "html"> </pre> page
<Pre> </pre>
<Pre name = "code" class = "javascript"> function querySub (id, sid/* selected item */) {</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> Page code: </p>
<P> </p> <pre name = "code" class = "javascript"> <pre name = "code" class = "html"> <tr>
<Th> Level 1 topic </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> secondary topic </th>
<Td valign = "middle">
<S: select name = 'Article. subChannel. subid' list = "{}" headerKey = "" headerValue = "-select-"> </s: select>
<! -- <S: property value = "article. subChannel. subName"/>
--> </Td>
</Tr>
</Pre> <p> </p>
<Div> <br>
</Div>
<Pre> </pre>
<Br>
<P> </p>
<P> server </p>
<P> server </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 struct List <Map <String, Object> ();
If (channelId! = Null &&! ChannelId. equals ("")){
Channel tmp = new Channel ();
Tmp. setChannelId (Integer. parseInt (channelId ));
SubChannelList = subChannelDAO. listSubChannel (tmp );
For (Object oo: subChannelList ){
Map <String, Object> obj = new HashMap <String, Object> ();
SubChannel c = (SubChannel) oo;
Obj. put ("subId", c. getSubId ());
Obj. put ("subName", c. getSubName ());
List. add (obj );
}
}
String outStr = JsonUtil. toJSONStr (list );
Out. println (outStr );
} Catch (Exception e ){
E. printStackTrace ();
}
Out. flush ();
Out. close ();
Return null;
}
</Pre> <br>
Actually, it is quite concise <p> </p>
</Pre>