PDA

View Full Version : disable button AFTER submit not sending other form field values?



monaya
02-21-2009, 05:46 PM
I can't get a form button to become disabled (greyed out) and still get the form to submit:

<input name="btnsubmit" type="submit" id="btnsubmit" onclick="this.value='Please wait...';this.disabled = true;this.form.submit();" value="Submit"/>

This changes the text, disables the button, but when the form submits all other form fields come in empty?

This works and does the job, but I want to grey out the box or hide it
<input name="btnsubmit" type="submit" id="btnsubmit" onclick="this.value='Please wait...';this.disabled = disabled;this.form.submit();" value="Submit"/>

Dirt_Diver
02-21-2009, 05:58 PM
Here try reading over this

http://www.dynamicdrive.com/dynamicindex11/submitonce.htm

monaya
02-22-2009, 04:10 PM
I'll test the other one out. Currently, I'm using this code, but it only works in Mozilla, not IE or safari.

onClick="this.value='Please wait...';this.disabled = disabled;submitform();"


<SCRIPT language="JavaScript">
function submitform()
{
document.form1.submit();
}
</SCRIPT>

monaya
02-22-2009, 04:16 PM
I get the same problem with that script, It's a dynamic page written coldfusion. The Form is disabling the button, but the form fields are not being submitted...

monaya
02-22-2009, 05:58 PM
AHH. I realized what's happening. In my dynamic code I was checking if the form was submitted by the submit button using an IF statement which is what I always do.

My lack of knowledge about javascript didn't tell me that the button values weren't being submitted after being disabled. Basically its just a vehicle to submit the form but its basically useless afterward.

I used another form field to check if the form is being submitted and everything is smooth now.