473,386 Members | 1,864 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,386 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 34690
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.