Wrox Programmer Forums
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 4th, 2005, 11:00 AM
Authorized User
Join Date: Sep 2004
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Nitin_sharma Send a message via Yahoo to Nitin_sharma
Default Div Invisibility

Hi Guys,
I am trying to make a div invisible and make it visible only when YES radio button is checked on the screen.
I am not able to achieve this , any help would be appreciated.
The Code is given below:

<tr CLASS=TRBlueBg>
<td align=right>&nbsp;&nbsp;&nbsp;Auto Delete </td>
<td><INPUT TYPE="radio" NAME="auto_delete" value=1 >Yes
<INPUT TYPE="radio" NAME="auto_delete" value=0 checked>No</td>
<td colspan="6">&nbsp;&nbsp;</td>

<DIV name="sampleDiv" id="sampleDiv" "display:none">
<tr CLASS=TRBlueBg>
<td align=right>Expiry Date&nbsp;&nbsp;</td>
<td> <input type="text" disabled name="getexpirydate" size="30" maxlength="100">
<td> <input type="hidden" name="expirydate" size="30" maxlength="100">

Old February 4th, 2005, 11:11 AM
joefawcett's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

Add this to the onclick attribute of the "yes" radio button:
document.getElementById("sampleDiv").style.display = 'block'
and change the current tag to have style="display: none".
By the way, DIVs don't have a name property.

You may want to change to using style.visibility = "hidden" and style.visibility = "visible" if you wish to just hide the div rather than have it unrendered.


Joe (Microsoft MVP - XML)
Old February 4th, 2005, 11:41 AM
Authorized User
Join Date: Sep 2004
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Nitin_sharma Send a message via Yahoo to Nitin_sharma

Hi Joe,
I have tried this thing as well and it doesnt seems to work for some reason.
Does tables , forms structure also effect the div in any ways ?
I have checked my code many times i am closing all td , tr and tables properly.
cheers for help.

Old February 4th, 2005, 11:53 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 425
Thanks: 0
Thanked 3 Times in 3 Posts

When it's wrong... You can put a <div> between two table rows. Or any other element for that matter. Also 'display:none' as you use it:
means nothing. You probably want style="display: none".

Use it directly with the TR. What's the need for the DIV?

//\ =^..^=
Old January 24th, 2011, 06:13 PM
Registered User
Join Date: Aug 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb To make a div invisible

I Figure it out!

Make sure you have the runat="server" inside the div

<div id="examplediv" runat="server" class="mycssstyle" >

On your vb code you can now type
examplediv.Visible = False

This same rule applies for tables, and many other html controls. just make sure you have an ID and runat="server" property..

Last edited by williameduardo; January 24th, 2011 at 06:23 PM.. Reason: more information
Old February 20th, 2011, 09:42 PM
Friend of Wrox
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts

Yes, runat="server" is what tells the .NET engine to perform the necessary server side processing on the elements; otherwise it's not smart enough to find them.

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.

Similar Threads
Thread Thread Starter Forum Replies Last Post
div within a div and inherting the height brettdavis4 CSS Cascading Style Sheets 1 January 23rd, 2007 09:59 AM
Div shifts in IE abq23 CSS Cascading Style Sheets 2 July 29th, 2006 04:29 PM
Div again... Nitin_sharma HTML Code Clinic 3 February 11th, 2005 04:28 AM
div DSteven CSS Cascading Style Sheets 2 February 9th, 2005 11:36 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.