[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Cant hide first div

Posted on 2011-04-25
4
Medium Priority
?
459 Views
Last Modified: 2012-05-11
Hello,
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 ?
Thanks.
//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">
     :
     :
</div>

//javascript
  function toggle()
    {
   var ID;
   ID= prompt("Enter id \n\r");
    var a = document.getElementById('divId_'+ID);
    if (a.style.display=="inline")
    {
    a.style.display="none";
    }
    else if (a.style.display=="none")
    {
    a.style.display="inline";
    }
    else
    {
    a.style.display="block";
    a.style.display="none";
    }
    return false;
    }
0
Comment
Question by:Waponi
  • 2
4 Comments
 
LVL 20

Assisted Solution

by:Sathish David Kumar N
Sathish David  Kumar N earned 248 total points
ID: 35464602
give alert message as id

alert(ID)

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

Accepted Solution

by:
Michel Plungjan earned 252 total points
ID: 35464687
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 = a.style.display;
      if (disp=="inline") disp="none";
      else if (disp=="none")  disp="inline";
      else disp="none";
    }
  }
  return false;
}

Open in new window

0
 

Author Closing Comment

by:Waponi
ID: 35479361
Thanks,
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 35479414
Great

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

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often times it's very very easy to extend a volume on a Linux instance in AWS, but impossible to shrink it. I wanted to contribute to the experts-exchange community a way of providing a procedure that works on an AWS instance. It can also be used on…
LinkedIn blogging is great for networking, building up an audience, and expanding your influence as well. However, if you want to achieve these results, you need to work really hard to make your post worth liking and sharing. Here are 4 tips that ca…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

834 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