locked
innerHTML RRS feed

  • Question

  • I am submitting a lot of buttons.

    <button onclick="mv(1)"> 1. Pe2e4 </button><button onclick="mv(2)"> pe7e5 </button>

    It is changed to

    <button> 1. Pe2e4 </button><button> pe7e5 </button><button> 2. Ng1f3 </button>

    Instead I tried in the HTML <button onclick="moveit(event)">

    How do I know which button is picked. Is this hidden in  'this.'  ?

    Thank you 

    Wednesday, April 10, 2013 7:12 PM

Answers

  • Thank you, that worked well. I keyed in srcElement, and I added a period, and it showed I could use ID.

     function smov(event) {

    var eSrc = event.srcElement;

    var smpsrc = eSrc.id;

    var smnumb = Math.abs(smpsrc);

    afen = movnow[smnumb];

    Thanks

    • Marked as answer by my-ped01 Thursday, April 11, 2013 5:39 PM
    Thursday, April 11, 2013 5:39 PM

All replies

  • my-ped01,

    I am moving this over to the JavaScript/CSS/HTML forum.

    Best Wishes - Eric


    This posting is provided "AS IS" with no warranties, and confers no rights.

    Wednesday, April 10, 2013 8:32 PM
    Moderator
  • I did not get your question properly, but if you are looking at what button is clicked in a common click event handler, then you can check the id, class or details for the button in the srcElement (in the click event).

    Please share some code and I would be able to help you better.

    - Girija

    Wednesday, April 10, 2013 9:19 PM
  • Thank you, that worked well. I keyed in srcElement, and I added a period, and it showed I could use ID.

     function smov(event) {

    var eSrc = event.srcElement;

    var smpsrc = eSrc.id;

    var smnumb = Math.abs(smpsrc);

    afen = movnow[smnumb];

    Thanks

    • Marked as answer by my-ped01 Thursday, April 11, 2013 5:39 PM
    Thursday, April 11, 2013 5:39 PM