View Full Version : ButtonDisable Function

03-31-2011, 09:33 AM
Hello CF members,

i have this problem with my form. atm it has fields where you can write down your info in, a submit button to let it get sended/saved on a location on the server. a reset button and many more.

but now i have the problem that it goes wrong with 1 of the objects that a person has to select to let the submit button be enabled.

i have a function that says that several objects/fields must have a value of >0 amount of symbols.

this worked fine with the textboxes and Select option ( dropdown box ). but now i need a checkbox and thats where the trouble started.

when i filled in the code to activate the script for the function ( with onclick ) i thoughed i did everything right. but now it see's the value no matter if its unchecked or checked.

so if i fill in the other required fields/objects the button will become enabled because the checkbox is instantly submitting the value ( towards the function ) anyway.

which wasn't the case with the textboxes ( onKeyUp ) and the Select ( onclick + onKeyUp ) cause you include symbols yourself with the textboxes ( which activates the >0 ) and the selection of a other option that did had a value.

the standard selected option doesn't have a value, so thats why it didn't went wrong with the dropdown box. see the function and the textbox+dropdown box that i supported in this post

i already tested it out that when i remove the value of the checkbox the button stays disabled cause it doesn't get the >0 through.


now i know the basics of web programming but im not that far that i can spit out a solution for everything thats getting thrown at me and this is 1 of them.

but i do know that i could use a adjustments that doesn't rely on the value ( so adjustments at ip9 in the function.)
or that i need a code that sends the value after the checkbox has been checked.

or something totally different that will make it work :P

if any1 could support me with this then it would be More then appreciated :)

tyvm in advance,

greetings. me


- checkbox = ip9
- the name check2 is used for my (storage/sending) php code.


function ButtonDisable1(ip1,ip2,ip3,ip4,ip5,ip6,ip7,ip8,ip9,but){
if (ip1.replace(/\s/g).length>0&&ip2.replace(/\s/g).length>0&&ip3.replace(/\s/g).length>0&&ip4.replace(/\s/g).length>0&&ip5.replace(/\s/g).length>0&&ip6.replace(/\s/g).length>0&&ip7.replace(/\s/g).length>0&&ip8.replace(/\s/g).length>0&&ip9.replace(/\s/g).length>0){

Checkbox that doesn't work__________________________________________

<input type="checkbox" ID="check5" name="check2" onClick="ButtonDisable1('voor','achter','adres','prov','stad','postcode','telefoon','email','check5','submit_ button')" value="Akkoord"<?PHP print $check2; ?>>

Sample of 1 of the Textboxes that do work_____________________________

<td class="tdr">&nbsp;<font size="2">Achternaam:</td>
<td><input type="text" name="achter" value="<?php echo $achter; ?>" onKeyUp="ButtonDisable1('voor','achter','adres','prov','stad','postcode','telefoon','email','check5','submit_ button')"></td>

Dropdown Box that i had and worked__________________________________

<SELECT ID="check5" name="check2" width="150" onKeyUp="ButtonDisable1('voor','achter','adres','prov','stad','postcode','telefoon','email','check5','submit_ button')" onclick="ButtonDisable1('voor','achter','adres','prov','stad','postcode','telefoon','email','check5','submit_ button')" >
<option value="Akkoord" <?PHP print $check2; ?>> Ja *