tags:

views:

347

answers:

4

how do i call the doSubmit() function from the conFirmUpload() when the confirm msg box is true?

<script type="text/javascript">
    function confirmUpload() {
        if (confirm("Are you sure want to upload '" + document.getElementById("txtWS").value + "' ?") == true) {
            return true;
        }
        else
            return false;
    }

    function doSubmit(btnUpload) {
        if (typeof(Page_ClientValidate) == 'function' && Page_ClientValidate() == false) { 
            return false;
        }    
        btnUpload.disabled = 'disabled';
        btnUpload.value = 'Processing. This may take several minutes...';
        <%= ClientScript.GetPostBackEventReference(btnUpload, string.Empty) %>;    
    }
</script>
+3  A: 
var btnUpload = document.getElementById('buttonId');
doSubmit(btnUpload);

Put that in your if-block. Make sure the button has an ID.

geowa4
+1  A: 

Without knowing more What about this?

function confirmUpload(btnUpload) {
    if (confirm("Are you sure want to upload '" + document.getElementById("txtWS").value + "' ?") == true) {
        doSubmit(btnUpload);
    }
    else
        return false;
}
neilc
confirmUpload is probably a handler for the submit event, so you cant pass it the button.
geowa4
A: 
function confirmUpload() {
    if (confirm("Are you sure want to upload '" + document.getElementById("txtWS").value + "' ?") == true) {
        var btnUpload = document.getElementById('<%= btnUpload.ClientID %>');
        doSubmit(btnUpload);
    }
}
Canavar
A: 

Change the method prototype as

function confirmUpload(obj) {
//Do some thing
}

Where obj the the button you are clicking on

Call this method as

**onclick="javaScript:confirmUpload(this)"**

Now in that if part call another method like

if (confirm("Are you sure want to upload '" + document.getElementById("txtWS").value
    +     "' ?") == true) {
    doSubmit(obj);
}
Umesh Aawte
You should read how to format code, your answer could be much neater and better presented
neilc