简体   繁体   English

如何在1个输入类型内调用2个函数

[英]how to call 2 function inside 1 input type

function addRow(tableID) {

var table = document.getElementById(tableID); var rowCount = table.rows.length; var row = table.insertRow(rowCount); var colCount = table.rows[0].cells.length; for(var i=0; i<colCount; i++) { var newcell = row.insertCell(i); if (i==2) { newcell.innerHTML="<div id='txtHint"+xx+"'></div>"; } else if(i==0){ newcell.innerHTML = "<INPUT type='checkbox' name='chk[]'/>"; } else if (i==1) { newcell.innerHTML = table.rows[1].cells[1].innerHTML; switch(newcell.childNodes[0].type) { case "select-one": newcell.childNodes[0].setAttribute("onchange","showUser(this.value,"+xx+");showrole(this.value,"+xx+")"); } } else if (i==3) { newcell.innerHTML="<div id='txtHintrole"+xx+"'></div>"; }

this is my function show select option depend on username i choose after did some modification finally it work 这是我的功能显示选择选项取决于用户名,我做了一些修改后终于选择了它的工作

and now i want to show role depend on username so i have 2 show 现在我想显示角色取决于用户名,所以我有2个显示

1.for password 2.for username 1.用于密码2.用于用户名

onchange="showpassword(this.value) onchange =“ showpassword(this.value)

this is my onchange inside select box 这是我在选择框内的onchange

and now i want to showrole too 现在我也想炫耀

so when i choose the select it will showed me password and role ad diferent cell 因此,当我选择“选择”时,它将向我显示密码和不同角色的角色

newcell.childNodes[0].setAttribute("onchange","showUser(this.value,"+xx+");showrole(this.value,"+xx+")"); newcell.childNodes [0] .setAttribute(“ onchange”,“ showUser(this.value,” + xx +“); showrole(this.value,” + xx +“)”);

and i foudn that i have tu put semi colon to devide the function and i still show an error that the show only show role and it happen to 2 of them 而且我发现我已经用半冒号来定义功能了,但我仍然显示一个错误,表明演出只显示了角色,并且恰好发生在其中两个

it should showpassword and showrole when i select the value 当我选择值时,它应该显示密码和showrole

You can use the innerHTML property of the cell. 您可以使用单元格的innerHTML属性。

Do something like 做类似的事情

newcell.innerHTML = '<div id="txthint' + i + '">content</div>';

Hope this help 希望这个帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM