This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Problems to hide div Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Problems to hide div" Watch "Problems to hide div" New topic
Author

Problems to hide div

Janice Guevara
Greenhorn

Joined: Aug 07, 2006
Posts: 14
Hi, I can't hide a div that I have on my jsp...I think the problem may be that there is java code inside...any suggestions???

<div id="createDiv" class="hidden">
<c:if test="${canCreate}">
<tr>
<%for(int j=0;j<listColumns.size();j++){
pageColumns=(PageColumns)listColumns.get(j);

if(pageColumns.getType()=="input"){
%>

<td><input type="text" name="create_<%=pageColumns.getName()%>" /></td>
<%}
if(pageColumns.getType()=="checkbox"){
System.err.println("property ");
%>

<td>& lt;input type="checkbox" name="create_<%=pageColumns.getName()%>"/></td>
<%}
if(pageColumns.getType()=="list")
{
%>
<td>& lt;select id="create_<%=pageColumns.getName()%>" name="create_<%=pageColumns.getName()%>" multiple="multiple" size="5">
<logic:iterate name="CallerId" id="CallerId">
<option value="<bean:write name='CallerId' property='name' />">
<bean:write name="CallerId" property="callerid"/>
</option>
</logic:iterate>
</select>
</td>
<%
}
}
%>

</tr>
</c:if>
</div>


this is the button that I used and the javascript code:

function hide(identifiant) {

if (document.getElementById(identifiant).className == "hidden") {
document.getElementById(identifiant).className = "visible";
} else {
document.getElementById(identifiant).className = "hidden";
}
}

<td><input type="button" value="Create" onCclick="hide('createDiv')"/></td>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60791
    
  65

Originally posted by Janice Guevara:
I think the problem may be that there is java code inside...any suggestions?


Your thinking is not correct.

By the time that the browser gets the page and any JavaScript can execute, no Java exists on the page anymore. JSP is a server-side templating mechanism that creates HTML pages to be sent to the browser. Please read this article for more details.

Your first debuggng step should be to do a View Source in the browser to see what is being delivered. Verify that all the HTML and JavaScript are as you expect.
[ August 10, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Janice Guevara
Greenhorn

Joined: Aug 07, 2006
Posts: 14
yes,you are right about the html code generated by the jsp.

I looked at the source code of my jsp and everything seems ok to me...

This is the html code that I want to hide:

<tr>
<div id="createDiv" class="hidden">


<td><input type="text" name="create_extension" /></td>


<td><input type="text" name="create_name" /></td>


<td><input type="checkbox" name="create_availableFromIVR"/></td>


<td><input type="checkbox" name="create_voicemailFlag"/></td>


<td><input type="text" name="create_mailbox" /></td>


<td><input type="text" name="create_email" /></td>

<td><select id="create_telephones" name="create_telephones" multiple="multiple" size="5">
<option value="mbonheur">
Monsieur Bonheur
</option>
</select>
</td>

<td><input type="text" name="create_password" /></td>

</div>
</tr>

and again the javascript function:

function hide(identifiant) {

if (document.getElementById(identifiant).className == "hidden") {
document.getElementById(identifiant).className = "visible";
} else {
document.getElementById(identifiant).className = "hidden";
}
}

I call the function with this button that is located in another part of my page:

<td><input type="button" value="Create" onCclick="hide('createDiv')"/></td>

just in case I didn't write correctly the onclick event in order to post this reply

thanks...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60791
    
  65

From this point on, it's an HTML and Javascript issue so I;ve moved this over to the HTML forum.
Janice Guevara
Greenhorn

Joined: Aug 07, 2006
Posts: 14
thanks, I didn't notice there was an HTMl forum...

I hope someone can help me
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60791
    
  65

Your HTML is malformed:



You can't have a div outside of a <td> or <th> within a table.
Samuel Lugo
Greenhorn

Joined: Feb 28, 2005
Posts: 24
Hello,

What do your 'hidden' and 'visible' CSS classes look like?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problems to hide div
 
Similar Threads
Issue with displaying data back on the page
Problems to hide div
Ajax, Struts, and a few pesky event based issues
Help me about html:select
Problems to hide div