Paul Baiju
Paul Baiju

Reputation: 419

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

Upvotes: 1

Views: 1698

Answers (1)

Emre Kabaoglu
Emre Kabaoglu

Reputation: 13146

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;
}

Upvotes: 4

Related Questions