RLJ Posted March 25, 2011 Share Posted March 25, 2011 Hi all, I have the following simple function that should check what the value of "srvce" is and enable/disable and check/uncheck checkboxes "checkpw" and "checkph" accordingly. Then the 2nd part of the script should check whether "checkpw" and "checkph" are checked or not and make some style changes to certain form elements accordingly. function enable(srvce,checkpw,checkph,labelpw,labelph,spanpw,spanph,lowerpw,lowerph,upperpw,upperph) { var value = document.getElementById(srvce).value; if(value=='Audio Translation' OR value=='Subtitling') { document.getElementById(checkpw).disabled= false; document.getElementById(checkph).disabled= false; document.getElementById(checkpw).checked= true; document.getElementById(checkph).checked= false; } if(value=='Document Translation' OR value=='Transcription Services' OR value=='Proof Reading Services') { document.getElementById(checkpw).disabled= false; document.getElementById(checkph).disabled= true; document.getElementById(checkpw).checked= true; document.getElementById(checkph).checked= false; } if(value=='Voiceover Services' OR value=='Interpreting' OR value=='Desktop Publishing') { document.getElementById(checkpw).disabled= true; document.getElementById(checkph).disabled= false; document.getElementById(checkpw).checked= false; document.getElementById(checkph).checked= true; } if(document.getElementById(checkpw).checked == true) { document.getElementById(labelpw).style.color= 'black'; document.getElementById(spanpw).style.color= 'black'; document.getElementById(lowerpw).disabled= false; document.getElementById(lowerpw).style.background='#FFFFFF'; document.getElementById(upperpw).disabled= false; document.getElementById(upperpw).style.background='#FFFFFF'; } else { document.getElementById(labelpw).style.color= '#808080'; document.getElementById(spanpw).style.color= '#808080'; document.getElementById(lowerpw).value = ''; document.getElementById(lowerpw).disabled= true; document.getElementById(lowerpw).style.background='#CCCCCC'; document.getElementById(upperpw).value = ''; document.getElementById(upperpw).disabled= true; document.getElementById(upperpw).style.background='#CCCCCC'; } if(document.getElementById(checkph).checked == true) { document.getElementById(labelph).style.color= 'black'; document.getElementById(spanph).style.color= 'black'; document.getElementById(lowerph).disabled= false; document.getElementById(lowerph).style.background='#FFFFFF'; document.getElementById(upperph).disabled= false; document.getElementById(upperph).style.background='#FFFFFF'; } else { document.getElementById(labelph).style.color= '#808080'; document.getElementById(spanph).style.color= '#808080'; document.getElementById(lowerph).value = ''; document.getElementById(lowerph).disabled= true; document.getElementById(lowerph).style.background='#CCCCCC'; document.getElementById(upperph).value = ''; document.getElementById(upperph).disabled= true; document.getElementById(upperph).style.background='#CCCCCC'; } } However, it is not working. When I run it, nothing changes. Can somebody see why? It's probably just a very simple mistake, I'm new to Javascript, but I can't spot it. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/231686-simple-javascript-function-not-working/ Share on other sites More sharing options...
RLJ Posted March 26, 2011 Author Share Posted March 26, 2011 Anyone? Pls help! I've looked over this a hundred times, I'm probably missing something very basic and stupid. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/231686-simple-javascript-function-not-working/#findComment-1192600 Share on other sites More sharing options...
RichardRotterdam Posted March 26, 2011 Share Posted March 26, 2011 I don't think the or operator is done that way for a start. It should be || And what javascript errors do you get? Quote Link to comment https://forums.phpfreaks.com/topic/231686-simple-javascript-function-not-working/#findComment-1192620 Share on other sites More sharing options...
RLJ Posted March 27, 2011 Author Share Posted March 27, 2011 Haha, yup, basic and stupid indeed. Changing OR to || worked. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/231686-simple-javascript-function-not-working/#findComment-1192910 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.