submit disable inside confirm alert

J

John

I'd like to disable the submit button after the user clicks it once,
but currently the submit button i'm using has a confirm alert. I've
tried to nest the disable within the confirmIT script but it causes it
to by pass the script completely. Any ideas?

Thanks, John

<script LANGUAGE="JavaScript">
<!--
function confirmIT()
{
var agree=confirm("To proceed, click OK.");
if (agree)
return true ;
else
return false ;
}
// -->
</script>

OR

<script LANGUAGE="JavaScript">
<!--
function confirmIT()
{
var agree=confirm("To proceed, click OK.");
if (agree)
var thisBTN = document.getElementById('Submit');
thisBTN.disabled = true
return true ;
else
return false ;
}
// -->
</script>
 
D

David Mark

I'd like to disable the submit button after the user clicks it once,
but currently the submit button i'm using has a confirm alert. I've
tried to nest the disable within the confirmIT script but it causes it
to by pass the script completely. Any ideas?

Thanks, John

<script LANGUAGE="JavaScript">

Change that to:

<script type="text/javascript">

Note to others, I know text/javascript is deprecated, but invalid is
worse than deprecated.

Anyway, that isn't your problem.

You don't need this.
function confirmIT()
{
var agree=confirm("To proceed, click OK.");
if (agree)
return true ;
else
return false ;}

Why not just return the result of confirm?

Or this.
</script>

OR

<script LANGUAGE="JavaScript">
<!--
function confirmIT()
{
var agree=confirm("To proceed, click OK.");
if (agree)
var thisBTN = document.getElementById('Submit');
thisBTN.disabled = true
return true ;
else
return false ;}

// -->
</script>

You didn't post the script that calls this thing. Something tells me
it is in the onclick handler of a form button, which then clumsily
calls onsubmit if confirmIT gives the green light. If so, see a
similar post from a few days ago, regarding a similar issue. If not,
post the rest of the code.
 
S

scripts.contact

I'd like to disable the submit button after the user clicks it once,

So you call the function on click event of button ? Bad.. use submit
event of form element:

<form onsubmit="return confirmIT(this)" .. >
....
<input type="submit">
....
I've
tried to nest the disable within the confirmIT script but it causes it
to by pass the script completely. Any ideas?

Yes, Change the function to:
function confirmIT(form){
if (confirm("To proceed, click OK.")){
form.elements.Submit.disabled=true
return true ;
}else return false
}
 
D

Darko

I'd like to disable the submit button after the user clicks it once,
but currently the submit button i'm using has a confirm alert. I've
tried to nest the disable within the confirmIT script but it causes it
to by pass the script completely. Any ideas?

Thanks, John

<script LANGUAGE="JavaScript">
<!--
function confirmIT()
{
var agree=confirm("To proceed, click OK.");
if (agree)
return true ;
else
return false ;}

// -->
</script>

OR

<script LANGUAGE="JavaScript">
<!--
function confirmIT()
{
var agree=confirm("To proceed, click OK.");
if (agree)
var thisBTN = document.getElementById('Submit');
thisBTN.disabled = true
return true ;
else
return false ;}

// -->
</script>

Your code has one key problem - you don't have the blocks defined.
if ( agree ) {
var thisBTN = ...
thisBTN.disabled = true;
return true;
} else
return false;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top