Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>One idea is to change </p> <pre><code>&lt;INPUT TYPE='BUTTON' NAME='EDIT_PRODUCT_FROM_SEARCH' ID="'.$row['alpha_p_ID'].'" VALUE='Delete'&gt; </code></pre> <p>to </p> <pre><code>echo '&lt;INPUT TYPE="BUTTON" NAME="EDIT_PRODUCT_FROM_SEARCH" ID=".$row['alpha_p_ID']." onclick="your_js_delete_function('.$row['alpha_p_ID'].');" VALUE="Delete"&gt;' </code></pre> <p>then in JS</p> <pre><code>function yourj_s_delete_function(id) { //do something // you could also id = $(this).attr('id'); } </code></pre> <p>You could also assign a class so that your </p> <pre><code>$('what to write here?').click(function() { }); </code></pre> <p>becomes</p> <pre><code>$('.delete_button').click(function() { var id = $(this).attr('id'); .... rest of the code }); </code></pre> <p>Note: if your <code>$row['alpha_p_id']</code> returns a numeric value it's a good practice a add a string value as a prefix as numbers only ID would cause markup validation to fail</p> <p>So you would change <code>ID="'.$row['alpha_p_ID'].'"</code> to <code>ID="btn_'.$row['alpha_p_ID'].'"</code> </p> <p>and you'd need to change </p> <pre><code>var id_str = $(this).attr('id'); var id=id_str.split("_", 1); </code></pre> <p><strong>UPDATE</strong></p> <p>As you mentioned that these buttons are created dynamically - you'll need to use <code>on()</code> method instead of `click - </p> <pre><code>$('.delete_button').on("click", function(event){ alert("I am clicked!"); }); </code></pre> <p><a href="http://api.jquery.com/on/" rel="nofollow">http://api.jquery.com/on/</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload