473,405 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

JavaScript Button OnClick Disable and Change Value

kestrel
1,071 Expert 1GB
i need a button, that onclick changes value to "Sending" and disables so the cant click it again
Heres what i have
Expand|Select|Wrap|Line Numbers
  1. <input type="button" value="Submit" onclick="this.disabled=1; this.form.submit();">
but i cant seem to make
Expand|Select|Wrap|Line Numbers
  1. this.value=Sending;
to work with the other two scripts in the button.

Is it possible?

--Thanks
Aug 6 '06 #1
4 34693
kestrel
1,071 Expert 1GB
NVM i figured it out
sorry
Aug 6 '06 #2
Frinavale
9,735 Expert Mod 8TB
How did you get it to work?
I'm having a similar problem. The button disables but it will not send the postback request.
Dec 22 '06 #3
I wouldn't do this in-line, but here you go as a function. You'll need to name the form also, by the way.

Put this in your HTML header:
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function submitted(){
    button1 = getElementsByName("submit")[0];
  3. form1 = getElementsByName("--place form name here--")[0];
  4. if (button1.value == "Submit"){
    button1.value="Sending...";
  5. form1.submit();}else {return false;}}
  6. </script>
  7.  
And here's the button code:
Expand|Select|Wrap|Line Numbers
  1. <input name="submit" type="button" value="Submit" 
  2. onclick="return submitted();">
Mar 8 '07 #4
Hello!

Well i modified the function and become that way:

function disableSubmit(botao,formulario){

document.getElementById(botao).value = "Processando...";

document.getElementById(botao).disabled = true;
document.formulario.submit();
}

and in the form, put in the form tag the following onSubmit satatement as follows:

<form method="post" name="formViagem" onSubmit=disableSubmit("gravarApenas","formViagem" );>

This way, the button be disabled and the form is submitted correctly (the user cannot press more than one time if the form is submitting).

[]s
Márcio
Apr 18 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.