Disabling button

S

Sonnich

Hi all!

Say, I have <button> or <input type="submit">, how do then disable
them once they are clicked?

I could not find the right thing on the net :-(

S
 
C

Curtis.DanielN

1)Find your button
ex:var myu_btn = document.getElementById("submit_btn");
2)disable it
myu_btn.disabled = true;

A button being disabled or inabled is just one of it's attributes.
Alternately you can search your page for all input tag elements where
the type attribute is 'button' or 'submit' and disable them. For more
info just google input tag attributes.
 
S

Sonnich

1)Find your button
ex:var myu_btn = document.getElementById("submit_btn");
2)disable it
myu_btn.disabled = true;

A button being disabled or inabled is just one of it's attributes.
Alternately you can search your page for all input tag elements where
the type attribute is 'button' or 'submit' and disable them. For more
info just google input tag attributes.
On Jan 30, 6:26 am, "Sonnich" <[email protected]> wrote:

Thanks

I found something like:

function disableSubmits(form)
{
for (var i = 0; i < form.elements.length; i++)
if (form.elements.type.toLowerCase() == 'submit')
form.elements.disabled = true;
}

and...

echo "<form method=post name='myform' action='".$sTemp."'
ONSUBMIT=\"if (this.submitted) return false; else
{ this.submitted = true; disableSubmits(this); return true; }\"

but my problem is that I have 2 buttons for submit (2 ways), and when
adding this only the first one works - it disable the buttons, but
also the functionality of the second one.

can anyone help

BR
S
 
E

Evertjan.

Sonnich wrote on 30 jan 2007 in comp.lang.javascript:
Hi all!

Say, I have <button> or <input type="submit">, how do then disable
them once they are clicked?

I could not find the right thing on the net :-(

<button
onclick='alert("No more");this.disabled=true'>
Click me once
</button>
 

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
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top