duanli9930 2016-01-25 05:54
浏览 52

javascript中的onclick事件[重复]

This question already has an answer here:

My english is not good but i need help please!!! I am adding dynamic rows to a table, within the row inputs used type checkbox. I need to use the onclick event checkbox, but I can't do.

 $('#nuevo').click(function() {

//adding a row

     var idusu = "<?php echo $idusuariologeado; ?>" ;
 var fila='<tr><td>&nbsp;</td>'+

 '<td><input name="idiomas_nombre[]" type="text" placeholder="Idioma" 
  class="form-control input-md"  /><input  name="idiomas_usu[]" type="text" 
   value="'+ idusu + '" > </td>'+

  '<td><input  name="" type="checkbox" value="1" ><input type="hidden" 
   name="idiomas_suficiencia[]" value="" /></td>'+

   '<td><input id="cb2"  name="" type="checkbox" onclick="updatebox()" 
   value="1" /><input type="text" name="idiomas_escritura[]"  /></td>'+

   '<td><input id="cb3"  name="" type="checkbox" value="1"  >
   <input type="hidden" name="idiomas_lectura[]" value="1" /></td>'+

   '<td align="center"><input id="cb4" name="" type="checkbox" value="1" >     
   <input type="text" name="idiomas_hablado[]" value="1" /></td></tr>';


 //row to table
$('#tab_logic').append(fila);




  });

the function I intend to use in the onclick

function updatebox()
{
var textbox = document.getElementById("idiomas_escritura");
var values = [];

if(document.getElementById('cb2').checked) {
    values.push("1");
}

if(document.getElementById('cb3').checked) {
    values.push("1");
}

if(document.getElementById('cb4').checked) {
    values.push("1");
}


    textbox.value = values.join(" ");
}

Please help me. Thank's

</div>
  • 写回答

1条回答 默认 最新

  • duanqiang9212 2016-01-25 05:57
    关注

    there is no tag with id="nuevo", just add id attribute to any element

    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路