javascript - AJAX inside if statement -


this onclick function. code without if statement runs perfectly. i'm trying test if sbmt equal 1 , remove row. once add if statement, row cannot removed. wrong code?

function taskonclick(row,task) {     var url = 'remove_task.asp?task='+task;      if (<%=("sbmt")%> === 1){          $(this).row.closest('tr').remove();         $.ajax({url: url, success: function(result){             alert(result);         }});     } }; 
<tr id="taskid">         <%             if objrs("reas") <> ""                 strreason = "<br/><br/><b style=""color: red"">reason: "&objrs("reas")&"</b>"             else                 strreason = ""             end if             response.write "<td onclick=""taskonclick(this,'"&objrs("task")&"')""><a href=""#"">" & objrs("task") & "<span>"&objrs("remk")& strreason & "</span></a></td>"             response.write "<td>" & objrs("ddat") & "</td>"             response.write "<td class=""days"" style=""text-align:center"">" & objrs("days") & "</td>"             response.write "<td >" & objrs("cdat") & "</td>"           %> </tr> 

updated

function taskonclick(row,task) {     var url = 'remove_task.asp?task='+task;     var sbmt = <%=objrs("sbmt")%>;  if (sbmt == '1'){      row.closest('tr').remove();  $.ajax({url: url, success: function(result){     alert(result); }}); } else if (sbmt == '0'){     alert("no"); } }; 

sql

strwhere = " acti= '1' "     strsql = "select task,ddat,ddat-trunc(sysdate) days,prog,pnam,remk,reas,nvl(to_char(cdat,'dd/mm/yyyy'),'inpg') cdat,sbmt task" & strwhere     strsql = strsql & "order prog,ddat" 

this line:

if (<%=("sbmt")%> === 1){  

is going written document following javascript:

if (sbmt === 1){  

javascript going assume sbmt javascript variable , test see if value strictly equal 1. don't see javascript variable name defined in code, going cause following error when javascript runs:

uncaught referenceerror: sbmt not defined

and, therefore, contents of if block never executed.


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -