close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

How to display a hidden area when a radio button is checked?

Thread began 7/27/2015 10:13 am by Nathon Jones Web Design | Last modified 7/27/2015 6:20 pm by Nathon Jones Web Design | 1168 views | 8 replies

Nathon Jones Web Design

But the function relies on "onclick" does it not? Therefore, if an item is selected as "checked" by default it won't run the onclick function will it.

Also, how do I change that function example you've provided to cope with more than two scenarios? I thought elseif might do it, but I think I'm trying to apply Classic ASP thinking to this type of thing and it, clearly, doesn't work...this is what I'm trying (that isn't working):

The function:

<script>
function hideorshow() {
if (document.getElementById('TMSAmembershipratesID1').checked) {
document.getElementById('reveal-if-notfamily').style.display = 'block';
} else if (document.getElementById('TMSAmembershipratesID2').checked) {
document.getElementById('reveal-if-notfamily').style.display = 'block';
} else if (document.getElementById('TMSAmembershipratesID3').checked) {
document.getElementById('reveal-if-notfamily').style.display = 'block';
} else if (document.getElementById('TMSAmembershipratesID4').checked) {
document.getElementById('reveal-if-family').style.display = 'block';
} else if (document.getElementById('TMSAmembershipratesID5').checked) {
document.getElementById('reveal-if-notfamily').style.display = 'block';
}
}
</script>



The CSS...

#reveal-if-family {
display: none;
}
#reveal-if-notfamily {
display: none;
}



The form...

<form>
<label class="col-sm-4 control-label" for="TMSAmembershipratesID">Type of Membership:</label>
<div class="col-sm-8">
<div class="radio">
<label class="control-label" for="TMSAmembershipratesID">
<input type="radio" name="TMSAmembershipratesID" id="TMSAmembershipratesID1" value="Individual Standard" checked onclick="hideorshow();">
Individual Standard (&pound;20.00 per year)
</label>
</div>
<div class="radio">
<label class="control-label" for="TMSAmembershipratesID">
<input type="radio" name="TMSAmembershipratesID" id="TMSAmembershipratesID3" value="Individual Premium" onclick="hideorshow();">
Individual Premium (&pound;50.00 per year)
</label>
</div>
<div class="radio">
<label class="control-label" for="TMSAmembershipratesID">
<input type="radio" name="TMSAmembershipratesID" id="TMSAmembershipratesID2" value="Individual Concession" onclick="hideorshow();">
Individual Concession (&pound;15.00 per year)
</label>
</div>
<div class="radio">
<label class="control-label" for="TMSAmembershipratesID">
<input type="radio" name="TMSAmembershipratesID" id="TMSAmembershipratesID4" value="Family" onclick="hideorshow();">
Family (&pound;30.00 per year)
</label>
</div>
<div class="radio">
<label class="control-label" for="TMSAmembershipratesID">
<input type="radio" name="TMSAmembershipratesID" id="TMSAmembershipratesID5" value="Affiliate" onclick="hideorshow();">
Affiliate (&pound;30.00 per year)
</label>
</div>
</div>
</form>



The Hide/Reveal stuff..

<div id="reveal-if-family">
<p>Form fields in here.</p>
</div>

<div id="reveal-if-notfamily">
<input name="form2NDADULT" id="form2NDADULT" type="hidden">
<input name="form1STCHILD" id="form1STCHILD" type="hidden">
<input name="form1STCHILDDOB" id="form1STCHILDDOB" type="hidden">
<input name="form2NDCHILD" id="form2NDCHILD" type="hidden">
<input name="form2NDCHILDDOB" id="form2NDCHILDDOB" type="hidden">
<input name="form3RDCHILD" id="form3RDCHILD" type="hidden">
<input name="form3RDCHILDDOB" id="form3RDCHILDDOB" type="hidden">
</div><!-- end reveal-if-notfamily -->



Thank you.
NJ

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...