There is a getdetails () function for handling clicks (and sending via Ajax), but now there are four to be, and js know (get a digit in the variable) which one was clicked ...

input type="button" name="submit" id="1" value="A:..." onClick = "getdetails()" ... input type="button" name="submit" id="4" value="D:..." onClick = "getdetails()" 

I do not know how to combine the intruded way: element.onclick = function(){ alert(this.id); } or not to do them with buttons?

    2 answers 2

    For example:

     <input type="button" name="submit" id="1" value="A:..." onClick = "getdetails(this)"> <input type="button" name="submit" id="2" value="A:..." onClick = "getdetails(this)"> <script> function getdetails(obj) { alert(obj.id); } </script> 
    • Thanks, it works, it's simple as always) - Shilgen
    • 3
      Please, but I advise you to avoid similar constructions: onClick = "getdetails (this)" and use addEventListener and attachEvent (IE8) - likerRr
     <input class="type" type="button" name="submit" id="1"> <script> $(function(){ $(".type").on("click", function(){ var id = $(this).attr("id"); alert(id); }); }); </script> 
    • thought so, but more code) - Shilgen