问题
My onclick
event only works on double click. I searched the previous similar questions also but none of them worked. Please if anyone can help me with this.
function getDetails(tablename,field)
{
goToFind("0"+tablename);
var prntid=sessionStorage.getItem('prnt_id');
$.ajax({
url: 'addresses/getAddressDetails',
type: "post",
data: {'tablename':tablename,'fld':field,'prntid':prntid},
success: function(data){
var obj = JSON.parse(data);
res=res.split("|");
var str="<center><input type='button' value='Exit' onclick=javascript:window.close();opener.window.focus();></center><br/><table border=1>";
str+="<tr>";
for(var i=0;i<res.length;i++)
{
str+="<th>"+res[i]+"</th>";
}
str+="</tr>";
for(j=0;j<obj.length;j++)
{
str+="<tr>";
for(i=0;i<res.length;i++)
{
str+="<td>"+obj[j][res[i]]+"</td>";
}
str+="</tr>";
}
str+="</table>";
z = window.open('', 'popUp','height=' + screen.height + ',width=' + screen.width + ',resizable=yes,scrollbars=yes,toolbar=yes,menubar=yes,location=yes');
z.focus();
z.document.open();
z.document.write(str);
}
});
}
Here I am calling my method from index page
<button class="w3-btn w3-brown" value='skip' onclick="getDetails('addresses','party_id')">Current Party Address</button>
来源:https://stackoverflow.com/questions/35270540/onclick-event-only-works-on-double-click