coldfusion - JavaScript enable button when checkbox checked -


I think this button should be disabled, and when the user checks a checkbox it needs to be enabled, Not working for me at all, the button remains inactive, I know that calling the onclick script because I have placed an alert in the script and it warns me ....

  & lt; Script type = "text / javascript" & gt; Function goFurther (if (document.getElementById ("id"). Checkeded == true) document.getElementById ("calculation"). Disabled = false; Else document.getElementById ("calculation"). Disabled = true;} & Lt; / script & gt; Style type = "Text / CSS"> Input [disabled] {Color: Gray; text-decoration: none;} & lt; / style & gt; & lt; CFOUTPUT Query = "qGetOpenItemsTrans"> gt; & lt; tr & gt; & lt; TD ALIGN = "CENTER" & gt; & lt; input type = "checkbox" name = "chkbx" id = '# id #' value = "# seq_claim_id #" onClick = "goFurther ()" unchecked = 0>  & lt; TD ALIGN = "CENTER"> #Inventory_ Date # & lt; / TD & gt; ; & Lt; TD ALIGN = "CENTER" & gt; # seq_claim_id # & lt; / TD> & lt; TD ALIGN = "C ENTER "& gt; # monthsClouded # & lt; / TD & gt; & lt; TD ALIGN =" CENTER "& gt; # Amount_Rcvd_by_FRG # & lt; / TD & gt; & lt; TD ALIGN =" CENTER "& gt; ; # Commission_Amate # & lt; / TD & gt; & lt; TD ALIGN = "CENTER" & gt; #Net_Retrieve # & lt; / TD & gt; & lt; / TR & gt; INPUT TYPE = "button" NAME = "calculation" VALUE = "calculate" onClick = "submit form ();" Style = "height: 35px; width: 150px; font-size: medium; font-weight: bold; color: green;" Disabled & gt;    

has been replaced by your name attribute ( Or linked with) id attibute, your work is also trying to get an element with the id value of id . However, your IDs are dynamic through your query loop. Pass the clicked element on the goFurther function, so that you have a direct reference to the element checked.

  & lt; Input type = "checkbox" name = "chkbx" id = '# id #' value = "# seq_claim_id #" onClick = "goFurther (this)" & gt; & Lt; INPUT type = "button" id = "calculation" VALUE = "calculate" onClick = "submit form ();" Style = "height: 35px; width: 150 px; font-size: medium; font-weight: bold; color: green;" Disabled & gt; & Lt; Script & gt; Function goFurther (elem) {if (elem.checked == true) document.getElementById ("calculation"). Disabled = false; Else document.getElementById ("Count"). Disabled = true; } & Lt; / Script & gt;   

You can also simplify your function by doing the following:

  function goFurther {elem} {document.getElementById ("calculation"). Disabled =! Elem.checked; }  Update    

On your styling issue, this is due to how CSS works. You have a disabled style selector that is defined in your CSS, but your in-line style is set to color: green , which will always be used for any defined stylesheets Guess at & lt; Style & gt; Input # count {color: green; } Input # Count [Disabled] {Color: Gray; Text-decoration: none; } & Lt; / Style & gt; & Lt; INPUT type = "button" id = "calculation" VALUE = "calculate" onClick = "submit form ();" Style = "height: 35px; width: 150px; font-size: medium; font-weight: bold;" Disabled & gt;

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -