I understand there are several ways to save checkbox information. The way that best fits this application is validating on the divID but the function is still not working. -
function checkCB() {
-
var inputs = document.getElementById(Filtered).getElementsByTagName('input');
-
for (var i=0; i<inputs.length ; i++)
-
{
-
var obj = inputs[i];
-
if(inputs[i].type == "checkbox") {
-
inputs[i].checked=false;
-
}
-
}
-
}
-
-
-
-
<input
-
type="checkbox"
-
class="checkbox"
-
id="Filtered"
-
name="title"
-
value="false"
-
/>
-
title
-
11 1867 acoder 16,027
Recognized Expert Moderator MVP
"Filtered" should be in quotes.
I managed to get the field in the URL showing the correct value onsubmit and the view source is correct as well. But the checkbox itself remains empty. -
function checkCB() {
-
var inputs = document.getElementById("Filtered").getElementsByTagName('input');
-
for (var i=0; i<inputs.length ; i++)
-
{
-
var obj = inputs[i];
-
if(inputs[i].type == "checkbox") {
-
inputs[i].checked="false";
-
}
-
}
-
}
-
-
-
<body onload="checkCB()">
-
-
<%
-
String title = request.getParameter("title");
-
if (title != "false")
-
{
-
title = "true";
-
}
-
%>
-
-
<input
-
type="checkbox"
-
class="checkbox"
-
id="Filtered"
-
name="title"
-
value="<%=title %>"
-
/>
-
title
-
acoder 16,027
Recognized Expert Moderator MVP
Filtered is the name of the checkbox, so if you try to get the input elements from there, you won't get anything. Look for the parent element container for the checkbox and then use getElementsByTa gName.
I do appreciate your feedback aCoder although I'm not sure I understand what I need to key in on.
acoder 16,027
Recognized Expert Moderator MVP
What exactly is checkCB() supposed to do? In your code, setting checked to false would mean that the checkbox is unchecked.
Once the checkbox is checked, the form is submitted to a second form. The second form includes the checkbox and I need it to be checked or unchecked depending on the user selection.
I must be getting mixed up if I am setting the box to false in my function.
acoder 16,027
Recognized Expert Moderator MVP
In that case, you don't even need JavaScript (though you could use JavaScript too).
A checkbox is only passed through if it is checked, so in your JSP code, check that the value exists. If it does, set the checked attribute to "checked" or "true" for the checkbox using JSP.
I have this working but is there a cleaner way to recheck checkboxes on pagination? -
<%
-
String[] categories = request.getParameterValues("category");
-
String category = "";
-
if(categories != null)
-
{
-
for(int ii = 0; ii < categories.length; ii++)
-
{
-
category += categories[ii];
-
}
-
}
-
%>
-
<div class="item">
-
<input
-
type="checkbox"
-
id="cb1"
-
name="category"
-
value="cb1"
-
<% if (categories.indexOf("cb1") == -1) {%>
-
<% } else { %>
-
checked="yes"
-
<% } %>
-
Checkbox 1
-
</div>
-
<div class="item">
-
<input
-
type="checkbox"
-
id="cb2"
-
name="category"
-
value="cb2"
-
<% if (categories.indexOf("cb2") == -1) {%>
-
<% } else { %>
-
checked="yes"
-
<% } %>
-
Checkbox 2
-
</div>
-
acoder 16,027
Recognized Expert Moderator MVP
The cleaner way would be to only check if checked: - <input
-
type="checkbox"
-
id="cb1"
-
name="category"
-
value="cb1"
-
<% if (categories.indexOf("cb1") != -1) {%>
-
checked
-
<% } %>>
-
Checkbox 1
-
Don't forget to close the tag.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Prem K Mehrotra |
last post by:
I come from Oracle background. In Oracle, when one wants to do a point
in time
recovery, one can specify recover database until timestmap. Oracle's
database maps to a db2 subsystem, i.e., in Oracle database means
entire database, i.e.. all tablespaces (including indexes).
I see only recover tablespace and recover indexspace (or index)
commands in db2.
Therefore, one has to specify all the tablespaces and indexspaces and
recover them
|
by: apple |
last post by:
UDB v8 fp 6a on AIX 5.1.0.0
Below is a manual incremental recover from compressed backup datasets.
With external compress backup datasets, can it be coded to do an
automatic incremental recover? The manual incremental recover works
just fine, but having trouble getting the automatic incremental recover
to work. Thanks for your help
# INCREMENTAL BACKUP
|
by: Steven |
last post by:
I create the checkboxes dynamically on my webform (aspx). after I create
them, when I check any of the checkboxes, nothing happens. Here is my code
...
ArrayList LayerNameList1 = LayerNameList;
CheckBox checkBoxArray;
int BoxCount = 0;
HtmlTableRow newRow;
HtmlTableCell FieldCell;
|
by: Stephan Bour |
last post by:
Hi,
I have a query page were users can check previous orders according to a
number of parameters. The query results are presented in a datalist and the
datasource is a sql query.
Since I capture the user name at logon, I thought I¹d provide a default
datalist with all the orders for that particular user at pageload. In that
case, I don't need to display the name information for the user in the
datalist. However, I need to keep the Name...
|
by: Stephan Bour |
last post by:
I repost this since I know how much some list people hate html posts ;-)
Hi,
I have a query page were users can check previous orders according to a
number of parameters. The query results are presented in a datalist and the
datasource is a sql query.
Since I capture the user name at logon, I thought I¹d provide a default
datalist with all the orders for that particular user at pageload. In that
case, I don't need to display the name...
| |
by: Antoine |
last post by:
Is there anything that can make my project run its pageload twice?
I added trace lines throughout code, and then checked recently.
Unless its a temporary issue (resolved by reboot etc) I definitely seem to
see pageload trace item being fired more than once, and a sizeable delay for
it to run through all the functions its already processed (on first load
anyway)!
I doubt it is going this in my development environment, in fact I am...
|
by: epigram |
last post by:
I've got a page that has a Panel object that I am dynamically adding
CheckBox controls to. The number of CheckBox controls and the name of each
control is based on a database query. I would like to know how I can query
for all the CheckBox controls on the page during postback and check their
checked attribute without using the name of each checkbox. I want to do
this in a generic way so that I don't have to requery the db or save the...
|
by: Wayne Wengert |
last post by:
I have a form that has a cbo set to TabIndex 0 (it is the only item set to
tabindex 0). On page Load if I step through the code that cbo LostFocus
event fires after other initializations are completed and after the
LostFocus event completes, that cbo gets focus and the form opens? Why is
that LostFocus event firing? Any hints on how to debug this?
Wayne
|
by: mike_dba |
last post by:
I have been testing the db2 recover command on a DB2 V8.2 Linux
database. The database contains a single partition. I am not
archiving logs but retaining them on disk. the backup image is to
disk as well. I performed the following in order :
1. OFFLINE BACKUP <time#1>
2. Create table S.T (c1 smallint)
3. Insert several rows into S.T - values 1,2,3,4,5
4. ONLINE BACKUP <time#2>
5. Insert several more rows 6,7,8,9
|
by: Chris Date |
last post by:
Hi
I´ve got a problem with my scrollable table.
It´s a weekscheduler table with 7 columns ( weekdays ) and dynamicaly rows ( time ).
So the rows starts at 0:00am and ends at 12:00pm ( 24:00h ).
There is a value in the database, with a timeshift value ( in minutes ).
For example, timeshift value = 480 (480: 60 = 8) --> set scrollbar to 8:00am.
How can i set the scrollbar by pageload to the timeshift value?
Here 2 jpgs about the scheduler...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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: 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...
|
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: 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: 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...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |