简体   繁体   中英

How to pass multiple parameters to a function from HTML during Onclick

I wanted to pass 3 arguments to a function from HTML by ID during Onclick

onclick="total(document.getElementById('start').value,document.getElementById('finish').value,document.getElementById('break').value)"

but this is giving me an error

total is not a function at HTMLButtonElement.onclick (auth.html:42) onclick @ auth.html:42

Why don't you pickup the dom values in the function.

onclick="total()"

function total()
{
    var inputa = document.getElementById('start').value;
    var inputb = document.getElementById('finish').value;
    var inputc = document.getElementById('break').value;
}

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM