新手求教~~~如图  
=======================================
<tr>
        <td class="common"  rowspan="2">听课记录:</td>
        <td class="common" rowspan="2"  colspan="5">
        <input type="checkbox" id="tk1"/>
        <input type="text" style="border:0;border-bottom:1 solid ;background:;"  name="tkjl1" onclick="calendar()"/>
        <input type="checkbox" id="tk2"/>
        <input type="text" style="border:0;border-bottom:1 solid ;background:;"  name="tkjl2" onclick="calendar()"/>
        <input type="checkbox" id="tk3"/>
        <input type="text" style="border:0;border-bottom:1 solid ;background:;"  name="tkjl3" onclick="calendar()"/>
        <input type="checkbox" id="tk4"/>
        <input type="text" style="border:0;border-bottom:1 solid ;background:;"  name="tkjl4" onclick="calendar()"/><br />
        <input type="checkbox" id="tk5"/>
        <input type="text" style="border:0;border-bottom:1 solid ;background:;"  name="tkjl5" onclick="calendar()"/>
        <input type="checkbox" id="tk6"/>
        <input type="text" style="border:0;border-bottom:1 solid ;background:;"  name="tkjl6" onclick="calendar()"/>
        <input type="checkbox" id="tk7"/>
        <input type="text" style="border:0;border-bottom:1 solid ;background:;"  name="tkjl7" onclick="calendar()"/>
        <input type="checkbox" id="tk8"/>
        <input type="text" style="border:0;border-bottom:1 solid ;background:;"  name="tkjl8" onclick="calendar()"/>
        </td>
    </tr>
=====================================
因为听课记录在表中是一个字段  是8次拼接出来的字符串
想不到更好的办法  就这么做了
现在想点击 checkbox 触发text的onclick事件  
或者点击checkbox 将calendar()的返回值赋予text
可以做到么?求高手指点

解决方案 »

  1.   

    在checkbox元素加上onclick事件:
    <input type="checkbox" id="tk8" onclick="calendar()"/>
    这样不行么?
      

  2.   

    看你的描述,应该是没问题的,可以用AJAX,效果会更好一点。
      

  3.   

    <input type="checkbox" id="tk8" onclick="calendar()"/>$("tk8").val();这样获得的值是 "on"
      

  4.   

    calendar()
    这个函数是网上down的  
      

  5.   

    这个好吧,我表示我没看懂,但根据你的要求写几句基于jquery的代码
    $("checkbox").click(function(){
       //看你命令都是一样的,暂且不改你代码,直接这样写吧,得到checkbox的name属性值
        var name = $(this).attr("name");  
       //得到它接下来的那个input[type='text']的id值
        var txtid = name.substring(0,2) + "jl" + name.substring(2);
       //让这个input[type='text']自己点一下,jquery好像有个next用法的,我就不查文档了
        $("#"+txtid).click();
    });
      

  6.   

    额我错了,上面最后一句改成$("input[name='" + texid + "']").click();
      

  7.   

    举个栗子
    <input type="checkbox" id="tk1" onclick="ckClick(this);" />
    <input type="text" style="border:0;border-bottom:1 solid ;background:;" name="tkjl1" onclick="calendar(this)"/><script>
    function ckClick(obj){
    if(obj.checked){
    var tkjl1=document.getElementsByName("tkjl1")[0];
    tkjl1.onclick();
    }
    }
    function calendar(obj){
    obj.value=obj.name;
    }

    </script>