jquery - Javascript Send parameters from button to function -



jquery - Javascript Send parameters from button to function -

$.getjson('/courthousemanagement/loadlawcourt/?cityid=' + id, function (result) { $('#justicecourttable').html(''); (var = 0; < result.length; i++) { var tablestring = '<tr>' + '<th>' + result[i].courtid + '</th>' + '<th><button type="button" class="btn btn-sm btn-primary" onclick="javascript:selectclaimant(' + result[i].courtid + ',\'' + result[i].name +');">update</button></th>'+ //problem here '<th><button type="button" class="btn btn-sm btn-primary" onclick="javascript:selectclaimant(' + result[i].courtid + ',\'' + result[i].name +');">delete</button></th>' //problem here tablestring += '</tr>'; $("#justicecourttable").append(tablestring); } }); } } function selectclaimant(courtid, name) { alert(courtid + name); }

i load datas table.if **i click "delete" or "update" button , ı want send courtid , name selected row.**i tried above code.when click "update" or "delete" button , below exception.

uncaught syntaxerror: unexpected number

when click button "selectclaimant" function never works.where miss exaclty ? how can send courtid , name on "update" or "delete" button click ?

any help appreciated.

thanks.

have tried this:

$.getjson('/courthousemanagement/loadlawcourt/?cityid=' + id, function (result) { $('#justicecourttable').html(''); for(var = 0; < result.length; i++){ var tablestring ='<tr><th>'+result[i].courtid + '</th>' +'<th>'+ '<button type="button" class="btn btn-sm btn-primary" onclick="selectclaimant(\'' + result[i].courtid + '\',\'' + result[i].name +');">update</button></th>'+ '<th><button type="button" class="btn btn-sm btn-primary" onclick="selectclaimant(\'' + result[i].courtid + '\',\'' + result[i].name +');">delete</button></th>' tablestring += '</tr>'; $("#justicecourttable").append(tablestring); } });

also, it's possible find values way:

$.getjson('/courthousemanagement/loadlawcourt/?cityid=' + id, function (result) { $('#justicecourttable').html(''); for(var = 0; < result.length; i++){ var tablestring ='<tr><th>'+result[i].courtid + '</th>' +'<th>'+ '<button type="button" class="btn btn-sm btn-primary" data-courtid="'+result[i].courtid+'" data-name="'+result[i].name+'">update</button></th>'+ '<th><button type="button" class="btn btn-sm btn-primary" data-courtid="'+result[i].courtid+'" data-name="'+result[i].name+'">delete</button></th>' tablestring += '</tr>'; $("#justicecourttable").append(tablestring); } }); $(document).on('click', '#justicecourttable button', function(){ alert($(this).data('courtid')+' - '+$(this).data('name')); });

javascript jquery

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -