0

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>
0

4 Answers 4

3
var btnUpload = document.getElementById('buttonId');
doSubmit(btnUpload);

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

Sign up to request clarification or add additional context in comments.

Comments

1

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

1 Comment

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

Comments

0

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

1 Comment

You should read how to format code, your answer could be much neater and better presented

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.