Cant hide first div

Posted on 2011-04-25
Last Modified: 2012-05-11
I have a javascript function which hides  a <div> containing forms, tables, text, etc by passing in the id of the div.(For test purposes only)
The function works for all the div(s) except the very first.
Any suggestions why this would be the case ?
//jsp side
<tr><td><button  onclick="toggle();"><u>H</u>ide</button>                
<c:forEach items="${jobList.jobList}" var="job" varStatus="status">
 <div id="divId_${job.jobId}">
 <c:set var="formId" value="formId_${job.jobId}" />
 form:form name="jobForm" id ="${formId}" method="POST" action="jobmenu.htm"     commandName="job">

  function toggle()
   var ID;
   ID= prompt("Enter id \n\r");
    var a = document.getElementById('divId_'+ID);
    if ("inline")
    else if ("none")
    return false;
Question by:Waponi
    LVL 20

    Assisted Solution

    by:Sathish David Kumar N
    give alert message as id


    and right cilck of ur application view sources check whether both div id are same ?
    LVL 75

    Accepted Solution

    Why do you show and hide immediately after each other???

    Can you show the html produced? Perhaps the ID is not set for the first div

    Here is a cleaner script

    function toggle() {
      var ID = prompt("Enter id \n\r","");
      if (ID!="") {
        var a = document.getElementById('divId_'+ID);
        if (a) { // could be the user did not enter a correct ID
          var disp =;
          if (disp=="inline") disp="none";
          else if (disp=="none")  disp="inline";
          else disp="none";
      return false;

    Open in new window


    Author Closing Comment

    LVL 75

    Expert Comment

    by:Michel Plungjan

    Please note a typo I had
    else disp=="none";
    should be
    else disp="none";

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
    David Varnum recently wrote up his impressions of PRTG, based on a presentation by my colleague Christian at Tech Field Day at VMworld in Barcelona. Thanks David, for your detailed and honest evaluation!
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    755 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now