When I click on the button, it uses a function, I am now trying to make this name more I am "", then entered when
& lt; Img onclick = "addbeat ()" name = "item 1" src = "button.png" /> & Lt; Script & gt; Function addbeat () {simpleCart.add ({name: "", value: .99}); } & Lt; / Script & gt;
Update for
You have 2 options here. If you are going with an inline event handler, you can pass an event object to your click handler and access the image that clicked by using event.target
Such as:
& lt; Img onclick = "addbeat (event)" name = "item 1" src = "button.png" /> & Lt; Script & gt; Function addbeat (event) {simpleCart.add ({name: event.target.name, value: .99}); } & Lt; / Script & gt;
A better option (as discussed in the nearby discussion) will be programmatically attached to your click handler - at that point you will either have to go to event.target
or this
.
& lt; Img id = "animage" onclick = "addbeat (event)" name = "item 1" src = "button.png" /> & Lt; Script & gt; Function addbeat () {simpleCart.add ({name: this.name, price: .99}); } Document.getElementById ('anImage'). Onclick = addbeat; & Lt; / Script & gt;
No comments:
Post a Comment