title: AJAX inside if statement
body: <p>This is my <code>onclick</code> function. The code without the <code>if</code> statement runs perfectly. I'm trying to test if <code>sbmt</code> is equal to 1 and only then remove the row. But once I add the <code>if</code> statement, the row cannot be removed. What is wrong with my code?</p>
  
  <pre class="lang-js prettyprint-override"><code>function taskOnclick(row,task) {
      var url = 'remove_task.asp?task='+task;
  
      if (&lt;%=("SBMT")%&gt; === 1){ 
          $(this).row.closest('tr').remove();
          $.ajax({url: url, success: function(result){
              alert(result);
          }});
      }
  };
  </code></pre>
  
  <pre class="lang-vb prettyprint-override"><code>&lt;tr id="taskid"&gt;
          &lt;%
              If objRS("REAS") &lt;&gt; "" Then
                  strReason = "&lt;br/&gt;&lt;br/&gt;&lt;b style=""color: red""&gt;Reason: "&amp;objRS("REAS")&amp;"&lt;/b&gt;"
              Else
                  strReason = ""
              End If
              Response.Write "&lt;td onclick=""taskOnclick(this,'"&amp;objRS("TASK")&amp;"')""&gt;&lt;a href=""#""&gt;" &amp; objRS("TASK") &amp; "&lt;span&gt;"&amp;objRS("REMK")&amp; strReason &amp; "&lt;/span&gt;&lt;/a&gt;&lt;/td&gt;"
              Response.write "&lt;td&gt;" &amp; objRS("DDAT") &amp; "&lt;/td&gt;"
              Response.write "&lt;td class=""days"" style=""text-align:center""&gt;" &amp; objRS("DAYS") &amp; "&lt;/td&gt;"
              Response.write "&lt;td &gt;" &amp; objRS("CDAT") &amp; "&lt;/td&gt;"
  
  
          %&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p><strong>UPDATED</strong></p>
  
  <pre><code>function taskOnclick(row,task) {
      var url = 'remove_task.asp?task='+task;
      var SBMT = &lt;%=objRS("SBMT")%&gt;;
  
  if (SBMT == '1'){ 
      row.closest('tr').remove();
  
  $.ajax({url: url, success: function(result){
      alert(result);
  }});
  }
  else if (SBMT == '0'){
      alert("NO");
  }
  };
  </code></pre>
  
  <p><strong>SQL</strong></p>
  
  <pre><code>strWhere = " where acti= '1' "
      strSQL = "select task,ddat,ddat-trunc(sysdate) as days,prog,pnam,remk,reas,nvl(to_char(cdat,'dd/mm/yyyy'),'INPG') as cdat,sbmt from task" &amp; strWhere
      strSQL = strSQL &amp; "order by prog,ddat"
  </code></pre>