2

我想一次执行两个功能,

在我的代码下方:

<Script>

function checkSubmit(){

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

</Script>

按钮:

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

它没有执行 sendData() 函数,任何想法如何在一次 onclick 下执行这两个函数?

4

2 回答 2

2

更好地格式化您的代码,因为通常这应该可以正常工作

if(confirm('Are you sure you want to submit the data?')) { // no ; and open the bracket
    sendData();
}
于 2012-04-27T12:08:05.077 回答
1

试试这个代码:

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

function sendData() { alert("data sent"); }
于 2012-04-27T12:08:25.010 回答