I need to zero in on a specific section of my jsp form during a hide to uncheck the checkboxes in that section. Currently, anything I try either unchecks all checkboxes on the form or doesn't work at all. When I associated the specific section with ID the first box within the div is unchecked but not the second.
Suggestions? -
-
<div id="menu1" class=hide>
-
-
<div id="col1">
-
<input type="checkbox" name="Topic" value="_topic1" />topic 1 </div>
-
<div id="col2">
-
<input type="checkbox" name="Topic" value="_topic2" />topic 2 </div>
-
-
<div id="exit"><img src="/img/exit.gif" onclick="uncheck('menu1')" /></div>
-
</div>
-
-
<div id="menu2" class=hide>
-
-
<div id="col1">
-
<input type="checkbox" name="Topic" value="_topic3" />topic 3 </div>
-
<div id="col2">
-
<input type="checkbox" name="Topic" value="_topic4" />topic 4 </div>
-
-
<div id="exit"><img src="/img/exit.gif" onclick="uncheck('menu2')" /></div>
-
-
</div>
-
-
<div id="col1"> // always visable.
-
<div><input type="checkbox" name="Topic" value="_main1" /> main 1</div>
-
<div><input type="checkbox" name="Topic" value="_main2" /> main 2 </div>
-
<div><input type="checkbox" name="Topic" value="_main3" /> main 3 </div>
-
</div>
-
-
-html -
-
function uncheck()
-
{
-
document.getElementById("Topic").checked=false
-
}
-
-
/// or ////
-
-
function uncheck2(formname,checkname,state){
-
var checkboxes=eval("document.forms."+formname+"."+checkname)
-
for (cb=0;cb<checkboxes.length;cb++)
-
checkboxes[cb].checked=state
-
}
-
-
- javascript
12 4042 pbmods 5,821
Recognized Expert Expert
Heya, Swebster.
Why is there an eval() in this line? -
var checkboxes=eval("document.forms."+formname+"."+checkname)
-
This will work just as well, and more efficiently, to boot: -
var checkboxes = document.forms[formname][checkname];
-
But more importantly, document.forms[formname][checkname] only represents a singe element.
You will want to use getElementsByTa gName().
You will want to use getElementsByTa gName().
eval was incorrectly placed you're right..
In terms of tagName, would it be something simlar to; So by marking the tagname to div or id and using the jsf with the div in question it will uncheck those boxes? -
< onclick="uncheck2('menu1')"
-
- html -
document.getElementsByTagName("div").checked=false
-
- javascript
by setting the exact menu in the function below, the checkbox objects are set to false during onclick and the main checkboxes are untouched. With multiple menus to thing of a function would be needed for each one of them so there must be a more intelligent way. This deployment is in IE which is why I am using getAttribute. getAttribute('c lass') == 'show' works too but sets all the visible menu options to false and there are 20. Also, an error is returned with using a wildcard 'menu*' or 'menu[1-20]
Suggestions? Thanks -
function uncheck() {
-
var ins = document.getElementsByTagName('input');
-
for (var i=0; i<ins.length; i++) {
-
if (ins[i].getAttribute('id') == 'menu1') ins[i].checked =
-
false;
-
}
-
}
-
-
- javascript -
-
<div id="menu1" class=hide>
-
-
<div id="col1">
-
<input type="checkbox" name="Topic" value="_topic1" />topic 1 </div>
-
<div id="col2">
-
<input type="checkbox" name="Topic" value="_topic2" />topic 2 </div>
-
-
<div id="exit"><img src="/img/exit.gif" onclick="uncheck()" /></div>
-
</div>
-
-
<div id="menu2" class=hide>
-
-
<div id="col1">
-
<input type="checkbox" name="Topic" value="_topic3" />topic 3 </div>
-
<div id="col2">
-
<input type="checkbox" name="Topic" value="_topic4" />topic 4 </div>
-
-
<div id="exit"><img src="/img/exit.gif" onclick="uncheck()" /></div>
-
-
</div>
-
-
<div id="col1"> // always visable.
-
<div><input type="checkbox" name="Topic" value="_main1" /> main 1</div>
-
<div><input type="checkbox" name="Topic" value="_main2" /> main 2 </div>
-
<div><input type="checkbox" name="Topic" value="_main3" /> main 3 </div>
-
</div>
-
-
-
- html
pbmods 5,821
Recognized Expert Expert
Heya, Swebster.
Each Element has the getElementsByTa gName() method: -
var inputs = document.getElementById('divId').getElementsByTagName('input');
-
Pbmods,
including a checkbox=false statement triggering on the div id='menu * ' within the existing showhide function might be a little cleaner. Would you be able to assist? -
-
function checkall(formname,checkname,state){
-
var checkboxes=eval("document.forms."+formname+"."+checkname)
-
for (cb=0;cb<checkboxes.length;cb++)
-
{
-
var obj = checkboxes[cb];
-
if(obj.parentNode.parentNode.className!='hide')
-
{
-
obj.checked=state;
-
}
-
}
-
}
-
- javascript
[quote=swebster]Pbmods,
At a glance can you determine what is being done wrong here?
The function is not setting the specific checkboxes to false.
Thank you for your time. -
-
function resetCheckkboxes() {
-
var inputs = document.getElementsById('divId').getElementsByTagName('input');
-
for (var i=0; i<inputs.length; i++)
-
{
-
var obj = inputs[i];
-
if(obj.checkbox!='false')
-
{
-
obj.checked='false';
-
}
-
}
-
}
-
- javascript
Heya, Swebster.
Each Element has the getElementsByTa gName() method: -
var inputs = document.getElementById('divId').getElementsByTagName('input');
-
This returns an error;
Object doesn't support this property or method. -
function resetCheckboxes() {
-
var inputs = document.getElementsById('divId').getElementsByTagName('input');
-
for (var i=0; i<inputs.length; i++)
-
{
-
var obj = inputs[i];
-
if(obj.checkbox!='false')
-
{
-
obj.checked='false';
-
}
-
}
-
}
-
-
- javascript
acoder 16,027
Recognized Expert Moderator MVP
This returns an error;
Object doesn't support this property or method.
It's getElementById, not getElementsById .
You also seem to have multiple objects with the same id. That is incorrect. An id should be unique.
It's getElementById, not getElementsById .
You also seem to have multiple objects with the same id. That is incorrect. An id should be unique.
Thanks for the correction on getElementById. I now have a more clear error message.
'document.getEl ementById(...)' is null or not an object.
In terms of multiple objects, I have update the code to only have unique div id's for each of the menus and the checkboxes are now using class rather than div id.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: John Banta |
last post by:
Hi,
I have created a 12 month calendar where each day has a check box
whereby the user can indicate if that day is available or not
available for a certain event. The calendar is 'drawn' in a single
form rather than 12 separate forms.
If the checkbox contained in each day within each month has a unique
name such as 1August2003, 2August2003, etc, is there a way in
Javascript where I could have a button by each month where the user...
|
by: Sileesh |
last post by:
Hi
I have datagrid with 8 items. Out of which 2 items are checkboxes. Data is
binded dynamically to the datagrid
Based on some values from the database I have to check or uncheck the
checkbox in the datatgrid.
Does any one know how to do this?
|
by: Rekha |
last post by:
Hi
I have datagrid with 5 items. Out of which 1 items are checkboxes. The bool
column(checkbox column ) in added in datagrid. The rest of Data is binded
dynamically to the datagrid
Based on some values from the database I have to check or uncheck the
checkbox in the datatgrid.
Does any one know how to do this in windows form?
|
by: Mike Fellows |
last post by:
I have created some checkboxes within a panel using the code below
Dim NewCheckbox As New CheckBox
Me.Panel2.Controls.Add(NewCheckbox)
NewCheckbox.Location = New Point(XLocation, YLocation)
NewCheckbox.AutoSize = True
NewCheckbox.Text = DS1.Tables(0).Rows(counter1)(0)
NewCheckbox.Name = "Checkbox" & counter1 + 1
|
by: rn5a |
last post by:
All the rows in a DataGrid, including the Header, are accompanied with
a CheckBox. I want that when the CheckBox in the Header is checked,
then all the CheckBoxes should automatically get checked. I set the
AutoPostBack property of the CheckBox in the Header to True & am
invoking a sub named 'CheckAllRows' on the CheckedChanged event of this
CheckBox. The CheckBox in the Header exists within the HeaderTemplate
of a TemplateColumn in the...
| |
by: BibhuAshish |
last post by:
Hi,
I want to check or uncheck a number of checkboxes by clicking an image.
My html code is given below:
<TABLE>
<TR>
<TD>
|
by: PeteOlcott |
last post by:
http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/grid/tests/test_change_structure.html
I would like to completely understand how GUI controls such as this
one are constructed. In the ideal case I would like to see all of the
source code for a complete working example of a ListBox of CheckBoxes.
|
by: Anuj |
last post by:
Hi, since sometime I'm stuck in a problem where I want to check or
uncheck all the checkboxes. If I'm choosing name for the checkbox
array as 'chkbx_ary' then I'm able to check/uncheck all the checkboxes
(code pasted below). But if name of the checkbox array is
'chkbx_ary' then it's failing. I want the name to be 'chkbx_ary'
because I want to access this array at server side.
Though one may not require to see php part but I'm still pasting...
|
by: dragon52 |
last post by:
Hi Everyone,
Not sure the following is possible to do.
The standard MS Access user interface has checkboxes on a number of menu pages, such as Tools/Options/View. I have been asked to find a way to automatically uncheck these controls by writing either a macro or module using VBA or any other method.
The idea is that the user, with limited access rights and technical know how, opens Access and just run a macro or click something to...
|
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,...
|
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...
| |
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,...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |