multiple functions in one onClick

Refresh

December 2018

Views

339 time

2

I want to execute two functions in one onclick,

below my code:

<Script>

function checkSubmit(){

if(confirm('Are you sure you want to submit the data?');)
    sendData();
}

</Script>

The button:

<input type="submit" id="send_data"  class="send_data" value="Send" onclick="checkSubmit()"/>

It is not executing the sendData() function, any ideas how to execute the two function under one onclick?

2 answers

2

Формат кода лучше, как правило, это должно работать нормально

if(confirm('Are you sure you want to submit the data?')) { // no ; and open the bracket
    sendData();
}
1

Попробуйте этот код:

function checkSubmit() { 
    if (confirm('Are you sure you want to submit the data?')) 
        sendData(); 
}

function sendData() { alert("data sent"); }