Js click radio to dynamically update table data, jsradio dynamic table
Tbody defines a tag
When the above changes, just splice it in js, And the splicing ends tbody.html (XXX)
<Script type = "text/javascript"> $ (function () {var quotas = {1: {name: "ICBC", oneTime: 1000}, 2: {name: "Agricultural Bank", oneTime: 800 },3: {name: "Bank of China", oneTime: 2000 },4: {name: "China Construction Bank", oneTime: 10 }}; $ (": radio "). click (function () {console.info ("click:" + $ (this ). val (); var quota = quotas [$ (this ). val ()]; var quotaHtml = []; quotaHtml = quotaHtml. concat (['<tr>', '<td>' + quota. name + '</td>', '<td>' + quota. oneTime + '</td>', '<td> 100 </td>', '<td> 100 </td> ', '<td> 100 </td>', '</td>']) console.info ("html:" + quotaHtml ); $ ("# quota" ).html (quotaHtml)}) ;}); </script>
<Body> <input type = "radio" name = "bank" value = "1"/> ICBC <input type = "radio" name = "bank" value = "2" /> Agricultural bank <input type = "radio" name = "bank" value = "3"/> bank of China <input type = "radio" name = "bank" value = "4 "/> China Construction Bank <br/> <table> <tr> <th> bank </th> <th> quota </th> <th> daily quota </th> <th> monthly quota </th> <th> what is the quota? </th> </tr> <tbody id = "quota"> </tbody> </table> </ body>