SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    Procrastinator Extraordinaire lucas's Avatar
    Join Date
    Oct 2000
    Location
    Springfield, Missouri, U.S.A.
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    having problems with script to disable/enable radio buttons

    can anyone tell me why this script i've pieced together will disable radio buttons but will not re-enable them?

    The script code:

    <SCRIPT>
    function yes(trigger) {
    if (trigger = 'false')
    {disableDiv.style.color ='black'; disableDiv2.style.color ='black';}
    else
    {disableDiv.style.color ='grey'; disableDiv2.style.color ='grey';}

    <!-- mainform.conditionalid.disabled=false; for text boxes
    <!-- mainform.conditionalid.disabled=true; for text boxes - under disable
    <!-- mainform.conditionalid.value=''; under disable

    for (var i=0; i<mainform.elements.length; i++) {
    if (mainform.elements[i].name == 'JointEff') {
    mainform.elements[i].disabled = trigger;
    }
    }
    }
    </SCRIPT>




    The complete code:


    <html>
    <head>
    <SCRIPT>
    function yes(trigger) {
    if (trigger = 'false')
    {disableDiv.style.color ='black'; disableDiv2.style.color ='black';}
    else
    {disableDiv.style.color ='grey'; disableDiv2.style.color ='grey';}

    <!-- mainform.conditionalid.disabled=false; for text boxes
    <!-- mainform.conditionalid.disabled=true; for text boxes - under disable
    <!-- mainform.conditionalid.value=''; under disable

    for (var i=0; i<mainform.elements.length; i++) {
    if (mainform.elements[i].name == 'JointEff') {
    mainform.elements[i].disabled = trigger;
    }
    }
    }
    </SCRIPT>
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <form name="mainform" action="budgetquote3.asp" method="POST">
    <table width="100%" border="0" cellpadding="0" cellspacing="0" bordercolor="#666666">
    <tr>
    <td height="57" valign="top" colspan="2">
    <p>Do You Want To Select Joint Efficiency?
    <input type="radio" name="selectje" value="radiobutton" onclick="yes(false);" CHECKED>
    Yes
    <input type="radio" name="selectje" value="radiobutton2" onclick="yes(true);">
    No</p>
    <p>&nbsp;</p>
    </td>
    </tr>
    <tr>
    <td height="28" width="176" valign="middle" align="right" bordercolor="#FFFFFF">
    <DIV ID="disableDiv" style="color:black"> Top Head: </div>
    </td>
    <td width="815" valign="middle" bordercolor="#FFFFFF">
    <DIV ID="disableDiv2" style="color:black">
    <input type="radio" name="JointEff" value="radiobutton">
    70%
    <input type="radio" name="JointEff" value="radiobutton">
    85%
    <input type="radio" name="JointEff" value="radiobutton">
    100% </div>
    </td>
    </tr>
    </table>
    </form>
    </body>
    </html>

  2. #2
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if (trigger = 'false') should be: if (trigger == 'false') ...

  3. #3
    Procrastinator Extraordinaire lucas's Avatar
    Join Date
    Oct 2000
    Location
    Springfield, Missouri, U.S.A.
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks.

    The final working script:


    Code:
    <SCRIPT>
    function disableelements(trigger, colorswitch, formname, groupname) {
    
    <!-- mainform.conditionalid.disabled=false; use to enable text boxes
    <!-- mainform.conditionalid.disabled=true; use to disable text boxes
    <!-- mainform.conditionalid.value=''; use to disable text boxes
    
    for (var i=0; i<formname.elements.length; i++) {
        if (formname.elements[i].name == groupname) {
          formname.elements[i].disabled = trigger;
        }
      }
    
    if (colorswitch == 'on')
    {disableDiv.style.color ='black'; disableDiv2.style.color ='black';}
    if (colorswitch == 'off')
    {disableDiv.style.color ='gray'; disableDiv2.style.color ='gray';}
    
    }
    </SCRIPT>



    The entire page code


    Code:
    <html>
    <head>
    <SCRIPT>
    function disableelements(trigger, colorswitch, formname, groupname) {
    
    <!-- mainform.conditionalid.disabled=false; use to enable text boxes
    <!-- mainform.conditionalid.disabled=true; use to disable text boxes
    <!-- mainform.conditionalid.value=''; use to disable text boxes
    
    for (var i=0; i<mainform.elements.length; i++) {
        if (formname.elements[i].name == groupname) {
          formname.elements[i].disabled = trigger;
        }
      }
    
    if (colorswitch == 'on')
    {disableDiv.style.color ='black'; disableDiv2.style.color ='black';}
    if (colorswitch == 'off')
    {disableDiv.style.color ='gray'; disableDiv2.style.color ='gray';}
    
    }
    </SCRIPT>
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
    <form name="mainform" action="budgetquote3.asp" method="POST">
      <table width="100%" border="0" cellpadding="0" cellspacing="0" bordercolor="#666666">
        <tr> 
          <td height="57" valign="top" colspan="2"> 
            <p>Do You Want To Select Joint Efficiency? 
              <input type="radio" name="selectje" value="radiobutton" onclick="disableelements(false,'on',this.form,'JointEff');" CHECKED>
              Yes 
              <input type="radio" name="selectje" value="radiobutton2" onclick="disableelements(true,'off',this.form,'JointEff');">
              No</p>
            <p>&nbsp;</p>
          </td>
        </tr>
        <tr> 
          <td height="28" width="176" valign="middle" align="right"> 
            <DIV ID="disableDiv"> Top Head: </div>
          </td>
          <td width="815" valign="middle"> 
            <DIV ID="disableDiv2"> 
              <input type="radio" name="JointEff" value="radiobutton">
              70% 
              <input type="radio" name="JointEff" value="radiobutton">
              85% 
              <input type="radio" name="JointEff" value="radiobutton">
              100% </div>
          </td>
        </tr>
      </table>
    </form>
    </body>
    </html>
    Last edited by lucas; Jul 24, 2001 at 12:54.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •