Javascript Display issue - will not display

Posted on 2013-10-09
Medium Priority
Last Modified: 2013-10-09
Dear Colleagues:

                           Maybe I am just staring at code too long but I can not find problems with the 'display' function.  Here is the code from my actual program - display function in relevant line works but javascript does not switch it on and off.

function DiscCountCheck() {
    if (document.getElementById('Multi').checked) {
        document.getElementById('NUMdiscs').style.display = 'block';
    } else {
        document.getElementById('NUMdiscs').style.display = 'none';


relevant line that calls:

<input type="radio" name="numDiscSet" id="Multi" value="Multi-Disc Set" onclick="javascript:DiscCountCheck();">Multi-Disc

...line that does not switch to display:block...

<span id="NUMdiscs" style="display:none" class="foo">  Number:  </span>

I am praying it is just something I can not 'see' because I have worked on this too long.  Suggestions?
Question by:Petrusvb
LVL 35

Expert Comment

ID: 39560239

Rather than set it to block to redisplay it, try setting it to a blank string "".

LVL 30

Accepted Solution

Alexandre Simões earned 2000 total points
ID: 39560311
You're not closing the function curly brace.
You close the if but not the function.
Here's the code fixed:
function DiscCountCheck() {
    if (document.getElementById('Multi').checked) {
        document.getElementById('NUMdiscs').style.display = 'block';
    } else {
        document.getElementById('NUMdiscs').style.display = 'none';

Open in new window


Author Closing Comment

ID: 39560614
Dear AlexCode:

                            I even looked for that miserable curly bracket and must have miscounted - I think I need to sleep.  However, clients push - so thank you very much.

Featured Post

7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.

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.

Join & Write a Comment

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question