Jquery如何实现以下功能

图片说明
左边的部门需要从数据库中动态获取,然后点击单选框后将值传入收件人的文本框中,万分感谢

自己生成右边的结构

 <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js"></script>
<table>
    <tr><td valign="top">收件人:<input type="text" id="txt" style="width:500px" /><input type="hidden" id="txtIds" name="ids" /><br />
        主题:....</td><td id="tdContact">通讯录<br />
<input type="checkbox" class="all" />全部<br />
<div><input type="checkbox" class="sub" />交通局<a href="#">↓</a></div>
<div style="display:none">
<input type="checkbox" value="1" />交通局1
<br /><input type="checkbox" value="2" />交通局2
<br /><input type="checkbox" value="3" />交通局3</div>
<div><input type="checkbox" class="sub" />xx区<a href="#">↓</a></div>
<div style="display:none">
<input type="checkbox" value="1" />xx区1
<br /><input type="checkbox" value="2" />xx区2
<br /><input type="checkbox" value="3" />xx区3</div>
        </td></tr>
</table>
<script>
    $('#tdContact a').click(function () {
        var ex = this.innerHTML == '↓';
        this.innerHTML = ex ? '↑' : '↓';
        $(this).parent().next()[ex ? 'show' : 'hide']();
        return false
    });
    $('#tdContact input').click(function () {
        var all = this.className == 'all', sub = this.className == 'sub',checked=this.checked;
        if (all) $('#tdContact input').prop('checked', checked);
        else if (sub) $(this).parent().next().find('input').prop('checked', checked);
        var txt = '', ids = '';
        $('#tdContact input[value]:checked').each(function () { txt += ',' + this.nextSibling.data; ids += ',' + this.value; });
        $('#txt').val(txt.substring(1));
        $('#txtIds').val(ids.substring(1));
    });
</script>

求源码 470061481@qq.com

http://www.cnblogs.com/xuanye/archive/2009/10/26/1590250.html

http://www.cnblogs.com/linzheng/archive/2010/10/30/1865088.html

 <!DOCTYPE html>
<html>
<head>
<script src="/jquery/jquery-1.11.1.min.js">
</script>
<script>
function show(self){
  if(self.checked){
    $('#wenjian').val(self.value);
  }else{
    $('#wenjian').val('');
  }
}
</script>
</head>
<body>
<input type='text' id='wenjian'/>
<input type='checkbox' value='交通局' onclick='show(this)'>
</body>
</html>

其实明白的人一眼就看出来这是站内信,右侧部门和人员都是级联的。并且是从数据库中读取,然后可以多选,选中后将值存放到文本框中,在下JQ弱爆了
实在没办法了,所以求大神帮忙。

http://hegz.iteye.com/blog/645905