I want to know if this writing of javascript is true??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Louloul
    New Member
    • Aug 2010
    • 7

    I want to know if this writing of javascript is true??

    Hello

    how the disabled function of special option from select switch off a fieldset??

    Code:
    <script type="text/javascript">
    function choose_a()
    {
    	var x= document.getElementsByName("level").selectedIndex;
           
            if (x == document.getElementById("1"))
    	{
    		document.l.E[0].disabled=true;
    document.l.E[1].disabled=true;
    document.l.E[2].disabled=true;
    document.l.S[0].disabled=true;
    document.l.S[1].disabled=true;
    document.l.S[2].disabled=true;document.l.S[3].disabled=true;
    document.l.S[4].disabled=true;
    document.l.S[5].disabled=true;
    document.l.S[6].disabled=true;
    document.l.S[7].disabled=true;
    document.l.S[8].disabled=true;
        }
    	}
    	else
    	if (x == document.getElementById("2"))
    	{
    		document.l.k.disabled="true";document.l.se.disabled="true";
    	}
    	else
    	if (x == document.getElementById("3"))
    	{
    	 document.l.k.disabled="true";document.l.el.disabled="true";
    	}
    }
    </script>
    </head>
     
    <body>
    <form method="post" action="" name=L>
        <table border="1" align="center"><Caption><h1>Registratiopn New Year</h1></caption>
        <tbody>
          <tr><td colspan="2" align=center>Level</td>
          </tr>
     
          <tr>
             <td colspan=2 align=center><select name="level">
              <option selected id="1" onClick=choose_a();>
                Kinder Garden
              </option>
     
              <option id="2" onClick=choose_a();>
                Elementary
              </option>
     
              <option id="3"onClick=choose_a();>
                Secondary
              </option>
            </select></td>
          </tr>
    Thanks
    Last edited by Dormilich; Aug 25 '10, 09:14 AM.
  • omerbutt
    Contributor
    • Nov 2006
    • 638

    #2
    this is all a mess even your question that you are asking is confusing and does not state that what are you trying to ask please write in straight and simple format what you want
    Regards,
    Omer Aslam

    Comment

    • Louloul
      New Member
      • Aug 2010
      • 7

      #3
      Thanks.
      Ok I will explain more, I create select element with 3 options and every option is related to a fieldset which contains(fields et) a number a radio options, so when I select an option the fieldset related to this option will be on(enable) and the other(fieldset containg the another radio options) will be off(disabled)
      I want to know how could I do this?

      Thanks for every single help

      Comment

      • Leen
        New Member
        • Aug 2010
        • 22

        #4
        ur welcome
        i will reply when i solve ur problem

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #5
          (one) general rout to go:
          select one option (use the change event)

          disable all radios/fieldset

          re-enable the radios/fieldset according to the select value (you need to define somewhere, which radios/fieldset to enable. e.g. if there belongs one fieldset to one option, you can save the fieldset’s id in the option’s value)

          Comment

          Working...