Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8920245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:13:13+00:00 2026-06-15T06:13:13+00:00

My code snippet for radio buttons is – <input type=radio name=isPush id=isPushYes <? if($isPush)

  • 0

My code snippet for radio buttons is –

<input type="radio" name="isPush" id="isPushYes" <? if($isPush) {?>checked="checked"<?}?> value="<?= $isPush;?>" > <? echo "Yes"?></input>
<input type="radio" name="isPush" id="isPushNo" <? if(!$isPush) {?>checked="checked"<?}?> value="<?= $isPush;?>" > <? echo "No"?></input>
<table id="emailTable"><tr><td>...</td></tr></table>

The value of isPush will be 0 or 1. So one of my radio buttons will always be selected. And selecting either of the radio buttons initially is not in my hands.

Now, For the table, I want to set display: none when when second radio button is selected and set display: visible when first radio button is selected.

So which event should I put? I certainly can’t put onclick.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:13:14+00:00Added an answer on June 15, 2026 at 6:13 am

    You need to check the selected radio onload, as well as onchange. This means the table will be hidden to start with, if No is selected by default.

    jsFiddle Demo

    function checkRadio()
    {
            var tbl = document.getElementById("emailTable");
    
            if(document.getElementById("isPushYes").checked)
            {
               tbl.style.display = "";
            }
            else
            {
                tbl.style.display = "none";
            }   
    }
    
    window.onload = function()
    {
        document.getElementById("isPushYes").onchange = checkRadio;
        document.getElementById("isPushNo").onchange = checkRadio;
    
        checkRadio();
    }​
    

    Another option is without the onload event, you set the display with PHP:

    <table id="emailTable" <?php if(!$isPush) echo 'style="display:none"'; ?>><tr><td>...</td></tr></table>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm using a js snippet of ryan fait http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/ when i submit my form
I have been trying to get simple YES/NO radio buttons list working but facing
I have an input[type=radio] element inside a block container of fixed width. The supporting
Given the code bellow, how do I style the radio buttons to be next
Code Snippet: ShippingPeriod[] arrShippingPeriods; . . . List<ShippingPeriod> shippingPeriods = ShippingPeriodList.ToList<ShippingPeriod>(); The Last line
Code snippet (normal pointer) int *pi = new int; int i = 90; pi
Code snippet.. if (regionalApprover == null) { throw new Exception(string.Format(The regional approver for {0}
The code snippet: C2DMessaging.java public class C2DMessaging { public static final String EXTRA_SENDER =
This code snippet is from C# in Depth static bool AreReferencesEqual<T>(T first, T second)
Which code snippet will give better performance? The below code segments were written in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.