how to hide the form after unchecked the radio button

Why my form are still appear when the radio button is unchecked?amend_script.php
Lyka mdAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Here is a more generic way of doing this.
One function called for all events
Each radio has a custom data attribute (data-target) that specifies which div you must show for that radio
Add a class to the div's so we can find them and style them
<html>
<head>
<style type="text/css">
 .yesnoform {
  display: none;
 }
</style>
</head>
<body>
<script type="text/javascript">

function yesnoCheck(el)
{
  var target = el.dataset.target;
  var docs = document.getElementsByClassName('yesnoform');
  for(var i = 0; i< docs.length; i++) {
    if (docs[i].id == target) {
      docs[i].style.display = 'block';
    }
    else {
      docs[i].style.display = 'none';
    }
  }
}
</script>

<label>NEW COMPANY'S PARTICULAR(Butiran Syarikat Yang Baru)</label>
<input type="radio" onclick="yesnoCheck(this);" name="yesno" id="yesCheck" data-target="ifYes">
    <div id="ifYes" class="yesnoform">
  
        <label>New Company Name</label><br>Nama Syarikat Yang Baru</br>
    <input type='text' id='newcomp' name='newcomp'><br>
          <label>New Company Address</label><br>Alamat Syarikat Yang Baru</br> 
      <input type='text' id="newcompAdd" name='newcompAdd'>
    </div><br>
  
  <label>Particulars of New Representative of the company(Perubahan terhadap wakil syarikat)</label>
  <input type="radio" onclick="javascript:yesnoCheck(this);" name="yesno" id="yesCheck1" data-target="ifYes1">
    <div id="ifYes1" class="yesnoform">
  
        <label>New Representative Title</label><br>Gelaran Wakil Syarikat Yang Baru</br> <input type='text' id='yes' name='yes'><br>
    <label>New Representative Name</label><br>Nama Wakil Syarikat Yang Baru</br> <input type='text' id='yes' name='yes'><br>
          <label>New Representative's Address</label><br>Alamat Wakil Syarikat  Syarikat Yang Baru</br>  <input type='text' id='acc' name='acc'><br>
        <label>New Representative IC number</label><br>Nombor IC Wakil Syarikat Yang Baru</br> <input type='text' id='yes' name='yes'><br>
          <label>New Representative IC color</label><br>Warna IC Wakil Syarikat Yang Baru</br>  <input type='text' id='acc' name='acc'><br>
     <label>New Representative Phone Number</label><br>Nombor Telefon Wakil Syarikat Yang Baru</br> <input type='text' id='yes' name='yes'><br>
     <label>New Representative's Position</label><br>Pangkat Wakil Syarikat Yang Baru</br> <input type='text' id='yes' name='yes'><br>
     <label>Please upload the authorization Letter from your company</label><br>Sila muat naik Surat Pengesahan Dari Syarikat awda</br> <input type='file' id='yes' name='upload_files'><br>
    </div><br>
  
  <label>NEW PRODUCT'S PRESENTATION(Presentasi produk Yang Baru)</label>
  <input type="radio" onclick="javascript:yesnoCheck(this);" name="yesno" id="yesCheck2" data-target="ifYes2">
    <div id="ifYes2" class="yesnoform">

  <p><input type="hidden" name="product_id" id="product_id" placeholder="product_id" value="" readonly/>
          
    <label class="control-label">Product Name(Nama Produk)</label>
          
  <input class="form-control" type="text" name="product_name" id="product_name" placeholder="Product Name" autocomplete="off" value="" required readonly/><div id="results4" class="result"> 
  
    <label>New Presentation Of the Product</label><br>Presentasi Produk Yang Baru</br>
  <input type='text' id='newpresentation' name='newpresentation'><br>
    </div><br>
</body>
</html>

Open in new window

Working sample here
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Lyka mdAuthor Commented:
thats help me a lot..thank ypu so much Julian
0
Julian HansenCommented:
You are most welcome Lyka
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
radio buttons

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.