Results 1 to 10 of 10

Thread: JScript Radio Buttons and checkboxes

  1. #1
    Join Date
    Dec 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JScript Radio Buttons and checkboxes

    Hi All,

    I have a question and I need your expert help.
    I would like to do the followings:

    I have 1 Check-box for Manual and Two radio Buttons for On and Off.
    I need to establish : When someone click the check-box - it would automatically disable the other two radio buttons and when the check-box is unchecked the radio buttons return to enabled.

    I have written the following:

    = My Code Starts Here ======================================

    <p><img border="0" src="buttonGL.png" style="left:10px;top:14px;width:100px;height:120px;text-align:left; position:absolute"></p>
    <div id="sys_m_sp" class="data" style="left:20px;top:38px;width:100px;height:60px;text-align:left; position:absolute">
    <input name="sysmodeSetpoint-cb" type="checkbox" value="1"onclick="sysmodeSetpoint.disables=true"/>Manual<br/>
    </br>
    <input name="sysModeSetpoint" type="radio" value="0" onclick="parent.toggleRadios(this)"/>Off<br/>
    <!-- <input name="sysModeSetpoint" type="radio" value="1" onclick="parent.toggleRadios(this)"/>Standby<br/> -->
    <input name="sysModeSetpoint" type="radio" value="3" onclick="parent.toggleRadios(this)"/>On
    </div>

    = My Code Ends Here ======================================

    I'm not getting anything at all - Please Help me I need it asap for a little project that I'm working on.

    Thanks in advance,
    Arye

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    When pasting a code, please remember to use [code] tags. That includes [ html ], [ code ], and [ php ].

    You could play around with something as simple as:
    Code:
    <input type="checkbox" id="manual" name="manual" />
    
    <input type="radio" id="on" name="automatic" />
    <input type="radio" id="off" name="automatic" />
    
    <script type="text/javascript">
    document.getElementById('manual').onchange = function(){
    document.getElementById('on').disabled = document.getElementById('off').disabled = (this.checked);
    }
    </script>
    Jeremy | jfein.net

  3. #3
    Join Date
    Dec 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you! but I can't use this code if I have 2 or three panels that are use to control a device - the radio buttons "jumps" from one to another.

    can you please help.

    Thanks in advanced
    Arye

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Please post a link to the page on your site that contains the problematic script so we can check it out.
    Please include ALL your code so that we can take a look at it, we can't do much without it. When you do post your code remember to use [code] tags. That includes [ html ], [ code ], and [ php ].
    Jeremy | jfein.net

  5. #5
    Join Date
    Dec 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi,

    thank you

    here is my code:

    =======================================================================================

    <html dir="ltr">

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Manual&nbsp; Off</title>
    </head>

    <body>
    <p><img border="0" src="buttonGL.png" style="left:10px;top:14px;width:100px;height:120px;text-align:left; position:absolute"></p>
    <!-- <div id ="Eng_On_man_div" class "data" style="left:20px;top:38px;width:100px;height:60px;text-align:left; position:absolute">
    <input type="checkbox" id="Eng_On_manual" name="manual" />Manual<br/>
    </br>
    <!--
    <input type="radio" id="Eng_On_on" name="automatic" />On</br>
    <input type="radio" id="Eng_On_off" name="automatic" />Off</br> -->
    <!-- <input id="Eng_On_on" name="automatic" type="radio" value="0" onclick="parent.toggleRadios(this)"/>On<br/>
    <input id="Eng_On_off" name="automatic" type="radio" value="3" onclick="parent.toggleRadios(this)"/>Off<br/>
    <script type="text/javascript">
    document.getElementById('Eng_On_manual').onchange = function(){
    document.getElementById('Eng_On_on').disabled = document.getElementById('Eng_On_off').disabled = (this.checked);
    }
    </script>
    </div> -->


    <div id="Eng_On_man_div" class="data" style="left:20px;top:38px;width:100px;height:60px;text-align:left; position:absolute">
    <input name="manual" id="Eng_On_manual"type="checkbox" />Manual<br/>
    </br>
    <input type="radio" id="Eng_On_on" name="automatic" value="0" onclick="parent.toggleRadios(this)" />On<br/>
    <input type="radio" id="Eng_On_off" name="automatic" value="3" onclick="parent.toggleRadios(this)" />Off<br/>
    <script type="text/javascript">
    document.getElementById('Eng_On_manual').onchange = function(){
    document.getElementById('Eng_On_on').disabled = document.getElementById('Eng_On_off').disabled = (this.checked);
    }
    </script>
    </div>



    <p><img border="0" src="buttonGL.png" style="left:135px;top:14px;width:100px;height:120px;text-align:left; position:absolute"></p>

    <div id ="SM_ps1_man_div" class="data" style="left:145px;top:38px;width:100px;height:60px;text-align:left; position:absolute">
    <input name="manual" id="SM_ps1_manual"type="checkbox"/>Manual<br/>
    </br>
    <input type="radio" id="SM_ps1_on" name="automatic" value="0" onclick="parent.toggleRadios(this)"/>On<br/>
    <input type="radio" id="SM_ps1_off" name="automatic" value="3" onclick="parent.toggleRadios(this)"/>Off<br/>
    <script type="text/javascript">
    document.getElementById('SM_ps1_manual').onchange = function(){
    document.getElementById('SM_ps1_on').disabled = document.getElementById('SM_ps1_off').disabled = (this.checked);
    }
    </script>
    </div>

    </body>

    </html>

    ==========================================================================

    Thanks again.
    Arye

  6. #6
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    What do you mean it "jumps?"
    Jeremy | jfein.net

  7. #7
    Join Date
    Dec 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    When I click on a radio button in the Eng_On_man_div I have a black checking at the one I have clicked on. But when I click on another one from the second div SM_ps1_man_div the radio button that had a checking next to it before doesn't have it any more and the new radio button that was clicked at the end has the checking next to it - meaning that I have only one checking black dot all the time - i would like to have several checking dot for indication in each set of radio buttons - is that possible?

    Thanks for your help
    Arye

  8. #8
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    This is because you're grouping all of your radio buttons, as an example:
    Code:
    <input type="radio" name="food" value="Orange" />
    <input type="radio" name="food" value="Banana" />
    <input type="radio" name="food" value="Plum" />
    <input type="radio" name="food" value="Cheese" />
    Because all of these check boxes have the same name, they will "jump" from one to the other.
    Jeremy | jfein.net

  9. #9
    Join Date
    Dec 2010
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you very much You have been a great help!

  10. #10
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    No problem, I'm glad to help

    Here on DD, we like to keep things organized. In an effort to do so, you have the option to set a thread to resolved when an issue is fixed. To make the status of the thread resolved:
    1. Go to your first post
    2. Edit your first post
    3. Click "Go Advanced"
    4. In the dropdown next to the title, select "RESOLVED"
    Jeremy | jfein.net

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
  •