...

View Full Version : ButtonDisable Function



jack020
03-31-2011, 08: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





note:

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



Function__________________________________________________________


function ButtonDisable1(ip1,ip2,ip3,ip4,ip5,ip6,ip7,ip8,ip9,but){
ip1=document.getElementById(ip1).value;
ip2=document.getElementById(ip2).value;
ip3=document.getElementById(ip3).value;
ip4=document.getElementById(ip4).value;
ip5=document.getElementById(ip5).value;
ip6=document.getElementById(ip6).value;
ip7=document.getElementById(ip7).value;
ip8=document.getElementById(ip8).value;
ip9=document.getElementById(ip9).value;
but=document.getElementById(but);
but.setAttribute('disabled','disabled');
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){
but.removeAttribute('disabled');
}
}



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 SELECTED>
<option value="Akkoord" <?PHP print $check2; ?>> Ja *
</select>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum