473,884 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript for checkboxes in a table to get visible or not visible(asp.net control)

22 New Member
hi,
i have all elements(mostly chevkboxes) inside a table.if i check a check box the remaining checkboxes under it(placed in table) should be visible .i need to develop it in javascript pls help me out

sample code to give brief intro of my structure

Expand|Select|Wrap|Line Numbers
  1.  
  2. <table id="TABLE1" rules="none" runat="server" width="100%" >
  3. <tr>
  4. <td bgcolor="#6699ff" colspan="2">
  5. <asp:CheckBox ID="cbxProblemsEncounteredDuringSurgery" runat="server" 
  6. Text="Problems Encountered During Surgery" AutoPostBack="True" /></td>
  7. </tr>
  8. <tr>
  9. <td colspan="2">
  10. <table width="100%">
  11. <tr>
  12. <td>
  13. <asp:CheckBox ID="cbxConversionfromendoscopetoopenprocedure" runat="server" Text="Conversion from endoscope to open procedure" AutoPostBack="True" /></td>
  14. <td>
  15. <asp:CheckBox ID="cbxHemorrhage" runat="server"
  16. Text="Hemorrhage" AutoPostBack="True" /></td>
  17. </tr>
  18. <tr>
  19. <td>
  20. <asp:CheckBox ID="cbxProlongedsurgerybeyondavgduration" runat="server" Text="Prolonged surgery beyond avg.duration" AutoPostBack="True" /></td>
  21. <td>
  22. <asp:CheckBox ID="cbxUnplannedprocedurerequiringchangeofanaestheticplan" runat="server" Text="Unplanned procedure requiring change of anaesthetic plan" AutoPostBack="True" /></td>
  23. </tr>
  24. </table>
  25. </td>
  26. </tr>
  27. </table>
  28.  
if Problems Encountered During Surgery is checked then other elements in below "tr" which are again placed in a table must be enabled.ie dynamically visible
May 3 '07 #1
13 14370
cvijaykrishna
22 New Member
hi,
i have all elements(mostly chevkboxes) inside a table.if i check a check box the remaining checkboxes under it(placed in table) should be visible .i need to develop it in javascript pls help me out

sample code to give brief intro of my structure


<table id="TABLE1" rules="none" runat="server" width="100%" >
<tr>
<td bgcolor="#6699f f" colspan="2">
<asp:CheckBox ID="cbxProblems EncounteredDuri ngSurgery" runat="server"
Text="Problems Encountered During Surgery" AutoPostBack="T rue" /></td>
</tr>
<tr>
<td colspan="2">
<table width="100%">
<tr>
<td>
<asp:CheckBox ID="cbxConversi onfromendoscope toopenprocedure " runat="server" Text="Conversio n from endoscope to open procedure" AutoPostBack="T rue" /></td>
<td>
<asp:CheckBox ID="cbxHemorrha ge" runat="server"
Text="Hemorrhag e" AutoPostBack="T rue" /></td>
</tr>
<tr>
<td>
<asp:CheckBox ID="cbxProlonge dsurgerybeyonda vgduration" runat="server" Text="Prolonged surgery beyond avg.duration" AutoPostBack="T rue" /></td>
<td>
<asp:CheckBox ID="cbxUnplanne dprocedurerequi ringchangeofana estheticplan" runat="server" Text="Unplanned procedure requiring change of anaesthetic plan" AutoPostBack="T rue" /></td>
</tr>
</table>
</td>
</tr>
</table>


if Problems Encountered During Surgery is checked then other elements in below "tr" which are again placed in a table must be enabled.ie dynamically visible
May 3 '07 #2
r035198x
13,262 MVP
hi,
i have all elements(mostly chevkboxes) inside a table.if i check a check box the remaining checkboxes under it(placed in table) should be visible .i need to develop it in javascript pls help me out

sample code to give brief intro of my structure


<table id="TABLE1" rules="none" runat="server" width="100%" >
<tr>
<td bgcolor="#6699f f" colspan="2">
<asp:CheckBox ID="cbxProblems EncounteredDuri ngSurgery" runat="server"
Text="Problems Encountered During Surgery" AutoPostBack="T rue" /></td>
</tr>
<tr>
<td colspan="2">
<table width="100%">
<tr>
<td>
<asp:CheckBox ID="cbxConversi onfromendoscope toopenprocedure " runat="server" Text="Conversio n from endoscope to open procedure" AutoPostBack="T rue" /></td>
<td>
<asp:CheckBox ID="cbxHemorrha ge" runat="server"
Text="Hemorrhag e" AutoPostBack="T rue" /></td>
</tr>
<tr>
<td>
<asp:CheckBox ID="cbxProlonge dsurgerybeyonda vgduration" runat="server" Text="Prolonged surgery beyond avg.duration" AutoPostBack="T rue" /></td>
<td>
<asp:CheckBox ID="cbxUnplanne dprocedurerequi ringchangeofana estheticplan" runat="server" Text="Unplanned procedure requiring change of anaesthetic plan" AutoPostBack="T rue" /></td>
</tr>
</table>
</td>
</tr>
</table>


if Problems Encountered During Surgery is checked then other elements in below "tr" which are again placed in a table must be enabled.ie dynamically visible
You give the tr or td an id then you can use document.getEle mentById and set that element's style.display = "none".
Try it and post some code.
May 3 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
Do you want to simply hide and make visible or do you actually want to remove and display (in other words, the space taken by the checkboxes is added and removed from the screen)?
May 3 '07 #4
acoder
16,027 Recognized Expert Moderator MVP
I have merged the threads. Please do not double post.
May 3 '07 #5
cvijaykrishna
22 New Member
I have merged the threads. Please do not double post.
thank u very much . I DID IT ACCIDENTALLY .pls give me code for any sample table of that structure and also actually want to remove and display (in other words, the space taken by the checkboxes is added and removed from the screen)
May 4 '07 #6
cvijaykrishna
22 New Member
hank u very much . I DID IT ACCIDENTALLY .pls give me code for any sample table of that structure and also actually want to remove and display (in other words, the space taken by the checkboxes is added and removed from the screen)
May 4 '07 #7
acoder
16,027 Recognized Expert Moderator MVP
hank u very much . I DID IT ACCIDENTALLY .pls give me code for any sample table of that structure and also actually want to remove and display (in other words, the space taken by the checkboxes is added and removed from the screen)
I thought you might have done, but I couldn't be sure.

Get the id of the checkboxes and use the following code to display:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById(id).style.display='block';
and to hide:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById(id).style.display='none';
Replace id with the checkbox ids.

You'll want to trigger this "onclick":
[HTML]<input type="checkbox" onclick="toggle Display(this.ch ecked)">[/HTML] "this" refers to the checkbox which you click. checked is a boolean (true/false): whether it is checked or not. Based on that, you can display/remove.
May 4 '07 #8
cvijaykrishna
22 New Member
i am doing the same thing as directed by u but i need the checboxes to be read only & enabled when i uncheck& check the main checkbox respectively.

sample code

<script language="javas cript" type="text/javascript">

function show()
{
document.getEle mentById ('cbxConversion fromendoscopeto openprocedure') .style.display = 'block';
document.getEle mentById ('cbxHemorrhage ').style.visibi lity = true;
document.getEle mentById ('cbxProlongeds urgerybeyondavg duration').styl e.visibility = true;
document.getEle mentById ('cbxUnplannedp rocedurerequiri ngchangeofanaes theticplan').st yle.visibility = true;
}

function hide()
{
document.getEle mentById ('cbxConversion fromendoscopeto openprocedure') .style.display= 'none';
document.getEle mentById ('cbxHemorrhage ').style.displa y='none';
document.getEle mentById ('cbxProlongeds urgerybeyondavg duration').styl e.display='none ';
document.getEle mentById ('cbxUnplannedp rocedurerequiri ngchangeofanaes theticplan').st yle.display='no ne';
}
</script>

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArg s) Handles Me.Load
cbxProblemsEnco unteredDuringSu rgery.Attribute s.Add("Onclick" , "javascript:ret urn hide()")



End Sub

Protected Sub cbxProblemsEnco unteredDuringSu rgery_CheckedCh anged(ByVal sender As Object, ByVal e As System.EventArg s) Handles cbxProblemsEnco unteredDuringSu rgery.CheckedCh anged
If (cbxProblemsEnc ounteredDuringS urgery.Checked = True) Then
cbxProblemsEnco unteredDuringSu rgery.Attribute s.Add("Onclick" , "javascript:ret urn show()")

ElseIf (cbxProblemsEnc ounteredDuringS urgery.Checked = True) Then
cbxProblemsEnco unteredDuringSu rgery.Attribute s.Add("Onclick" , "javascript:ret urn hide()")
End If


End Sub



-------------------------------------------------------------------------------------------------------------------at page load its not getting enables but after i check the main check box its making the hide function to work.aftyer that even if i check the main checkbox the sub check boxes are not getting enabled
May 15 '07 #9
acoder
16,027 Recognized Expert Moderator MVP
You're mixing and matching the 'display' and 'visible' style properties.

Also, now do you want to enable/disable instead of show/hide?

To set something on page load, set its property to hidden or whatever.
May 15 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2721
by: Hong Kong Is A Good Place | last post by:
I am using a pivot table control (OWC) via web access to an analysis server. My connection string is: ci.ConnectionString = "Provider=MSOLAP.2;User ID=peterdev01\\" + the_username + ";Password=" + the_password + ";Data Source=http://peterdev01/webtest;Initial Catalog=Peter ALL v2;Integrated Security=SSPI;Persist Security Info=True;Client Cache Size=25;Auto Synch Period=10000"; ci.DataMember = "PIER cubes"
3
3843
by: Al Wilkerson | last post by:
Hey, I have a Web Form with a drop down list, textbox, and search button. When click the search button an SQL server database is queried fordata. Once I have the data in a dataset I use the dataset to dynamically create a Html Table control. I want to display the table on another frame page (target="main") without the web form controls (i.e. the textbox, search button, and dropdown list). I just want the table displayed only on the...
1
6352
by: Al Wilkerson | last post by:
Hey, I have a Web Form with a drop down list, textbox, and search button. When click the search button an SQL server database is queried fordata. Once I have the data in a dataset I use the dataset to dynamically create a Html Table control. I want to display the table on another frame page (target="main") without the web form controls (i.e. the textbox, search button, and dropdown list). I just want the table displayed only on the...
1
1268
by: Coach | last post by:
Is it possible to reference a html table control through code in C#? I want to be able to make a table visible/hidden. -- Coach
0
1065
by: WJ | last post by:
I am using html/Table control a lot to organize my controls on aspx form. Most of the time it works fine, then all of a sudden, a cell within a table refuses to be resized (left/right) and or a row will not resize. To fix this, I have to create a new table, copy everything from the old table to the new one and then I finally can resize the new table the way I want. Most of my html/table configurations are 2 columns with multiple rows...
1
1391
by: bbcrock | last post by:
Can Javascript control sections of a textarea using divs, etc? We have templates that unfortunately contain some free-text sections where our clients cannot come to aggreement. I would LOVE to do a div inside the textarea and modify it using ajax. I would also like to have a regular expression look for patterns inside the text area and highlight phone numbers. this kind of behavior doesn't seem possible. Unfortunately I'm in a break...
1
1449
by: Rohit111111 | last post by:
Hello How can i use the table control ,meanse i have to make rows and coloumn dynamically with proper pagination
0
1911
by: Scott LaChance | last post by:
I am programatically creating a Table control instance and embedding it in a RichTextBox control. I have registered event handlers for KeyUp. The UI generates the table and I can edit the individual cells, but I get no events firing for KeyUp (or KeyDown or ContextMenu). I'm trying to see if the Table control can serve as a table editor so I need it to interact with the user beyond its basic behavior.
3
5599
by: TheLymner | last post by:
I have, what I believe, is a rather simple question. However, I cannot find the answer anywhere on the web nor in any of the library of xml or javascript/asp books available. How do I pass and store an xml element data (an interger) into a javascript/asp variable? I am not going to display the data (that I can do easily), rather the data is going to used to deteremine how the rest of the parent data is going to be displayed in any of 90...
1
2906
by: realfantasy | last post by:
i made asp.net webusercontrol which contains panel which contains datalist and that panel is in ajax collapsableExtender and that webusercontrol is in master page header and in always visible control problem is little i think but very stupid that whenever i go on any page whilst page load my webusercontrol expand for a sec and then collapse but i want it to remain collapsed until i want it to expand.. you may see demo on...
0
9799
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11168
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10769
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10869
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10426
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7985
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7137
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5808
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4231
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.