html - JavaScript code is not working -


I am trying to code it, such as when I uncheck the check box, read drop-down menus only But currently only the second drop down menu is read, the first is not only read and editable, here's the problem? Why not read the first drop down check box only?

  & lt; Html & gt; & Lt; Top & gt; & Lt; Script type = "text / javascript" & gt; Function myFunction () {document.getElementById ("1"). Disabled = false; } Function mySecondFunction () {var ddl = document.getElementById ("1"); Var selectedValue = ddl.options [ddl.selectedIndex] .value; If (selected value == "exception, where") {document.getElementById ("mySelection"). Disabled = true; // set default document.getElementById ("mySelection"). Value = "OptionZero"} {document.getElementById ("mySelection"). Disabled = false; }} Function myThirdFunction () {document.getElementById ("mySelection"). Disabled = true; // set default document.getElementById ("mySelection"). Value = "OptionZero" // First drop down document.getElementById ("1"). Disable = true; Document.getElementById ("1"). Value = "OptionZero"} & lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Input type = "checkbox" name = "selectionbox" value = "yes" onclick = "myfunction ()" onchange = "myThirdFunction ()" /> & Lt; Select disabled id = "1" onchange = "mySecondFunction ()" & gt; & Lt; Option value = "OptionZero" & gt; Default & lt; / Options & gt; & Lt; Option value = "option on" & gt; Car & lt; / Options & gt; & Lt; Option value = "option two" & gt; Car 2 & lt; / Options & gt; & Lt; Option value = "option" "car 23  gt; & select; gt; & lt; br & gt; disabled id =" mys select "& gt; select & lt; Option value = "OptionZero"> Default  gt; Option value = "OptionOn">   C & lt; / option & gt; & lt; / select & gt; & lt; / body & gt; & Lt ; / Html>      

Your onClick event Is recalled after the on-change event, from which box 1 Try changing your onclick to it and remove your third function event.

  function myFunction () {if (document.getElementById ("1"). Disabled == false) {Document.getElementById ("mySelection"). Disable = true; // set default document.getElementById ("mySelection"). Value = "OptionZero" // First drop down document. GetElementById ("1"). Disable = true; Document.getElementById ("1"). Value = "OptionZero"} and {document.getElementById ("1"). Disabled = false; }}   

The order of the event calls may be different by the browser, so you should only have one event when the order output makes a difference.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -