I want to get a button onclick ID and apply it to another function.
<input type="button" onclick="recordToFilename();" id="submitdis" value="Enter Discount Price" />
And Apply it to
document.getElementById('discounts').innerHTML = "Discount : $" + ( - discountprice).toFixed(2);
Please check Codepen
Thanks for help
document.getElementById("submitdis")
function recordToFilename() {
var input = document.getElementById('submitdis'),
discount12 = input.value;
Try passing argument to your onclick function
<input type="button" onclick="recordToFilename(this);" id="submitdis" value="Enter Discount Price" />
function recordToFilename(ele)
{
console.log(ele.id);
}
Try:
function recordToFilename(e){
$(this).attr("Id")
//or:
e.Id
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.