473,666 Members | 2,581 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

checking and Unchecking checkbox using Javascript

Hi,
I have two checkboxes in each row of a grid. One for Modify and another one
for View. If I click Modify the View should get automatically checked and
should be disabled. Earlier I did this in server side and thing was working
fine. But when the user clicks the last row in the grid and make the modify
in that row to be checked the focus goes to the top of the page because of
page submission. so I did that using Javascript. Upto the operations in the
page i.e. upto the checking and disabling of view check box the process was
going very smooth. Afterwards when I try to insert the values of checkbox
into the database for Modify i.e the base checkbox(boased on this only the
View checkbox receives its status) the value was correct, but for View
checkbox the value it inserts in the database was false,eventhoug h it is
checked. Previously i was using web control. Now I am using HTMLControl
because of some unknown problems. Now if this gets corrected the work will
move smoothly. Can anyone help me in this regard.

Following is the code.

function CheckChangedEve nt(ctrl1,ctrl2)
{
var ctrlID1=documen t.getElementByI d(ctrl1);
var ctrlID2=documen t.getElementByI d(ctrl2);
ctrlID2.checked = true;
if(ctrlID1.chec ked == true)
{
ctrlID2.checked = true;
ctrlID2.disable d = true;
}
else if(ctrlID1.chec ked == false)
{
ctrlID2.checked = false;
ctrlID2.disable d = false;
}
}

and in server side am getting the value as follows.
ViewState["id_Modify_ chk"] =
Convert.ToInt32 (((HtmlInputChe ckBox)dg1.Cells[2].FindControl("_ gridChkModify") ).Checked);
ViewState["id_View_ch k"] =
Convert.ToInt32 (((HtmlInputChe ckBox)dg1.Cells[3].FindControl("_ gridChkView")). Checked);
int _modi_val = Convert.ToInt32 (ViewState["id_Modify_ chk"]);
int _view_val = Convert.ToInt32 (ViewState["id_View_ch k"]);

Thanks and Regards,
N.Ramakrishnan
Nov 21 '05 #1
1 5893
"Ramakrishn an Nagarajan" <ra**********@d iscussions.micr osoft.com> schrieb:
and in server side am getting the value as follows.
ViewState["id_Modify_ chk"] =
Convert.ToInt32 (((HtmlInputChe ckBox)dg1.Cells[2].FindControl("_ gridChkModify") ).Checked);
ViewState["id_View_ch k"] =
Convert.ToInt32 (((HtmlInputChe ckBox)dg1.Cells[3].FindControl("_ gridChkView")). Checked);
int _modi_val = Convert.ToInt32 (ViewState["id_Modify_ chk"]);
int _view_val = Convert.ToInt32 (ViewState["id_View_ch k"]);


ASP.NET-related questions will more likely get answered in one of the groups
inthe microsoft.publi c.dotnet.frame *work.aspnet[.*]" groups hierarchy.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
6612
by: Mike Lopez | last post by:
Hello. I need to set a checkbox to the "checked" state and prevent the user from unchecking it. I tried using "disabled", but then the value is not passed on the Post to an ASP page. Anyone have any ideas? Thanks in advance,
3
2334
by: Jack | last post by:
Hi, I have a form when loaded, retrieves record from an access table. Among other fields there is a check box called FinalUpdate. This is tied to a field in Access of type Yes/No. The form retieves the values perfectly. This form is being used to update the record in the table via a successconfirmation.asp. Now, when the checkbox is loaded as checked, then unchecking the checkbox reflects the change in query result in...
12
2287
by: Randell D. | last post by:
Folks, I have a form called "ourTestForm". Its a test form - nothing special - it contains five input tags - they are named one, two, three, four and five. The input tags are of type text,text,radio,checkbox and select. When I run the following code, it correctly reports "text" (for input
0
343
by: Pat Roy | last post by:
Hello... I've created a treeview that looks something like: Root .....Folder1 .........Subfolder1A .............File .............File .........Subfolder1B
2
6626
by: Maziar Aflatoun | last post by:
Hi everyone, I am reading and displaying data rows from my database where the first column contains the Status checkbox. I like to enable my users to change the status of individual rows by checking and unchecking the checkbox column. I like to update the status in the database for the column where the status was changed. This is what I'm doing so far
2
1470
by: Chelimar | last post by:
Hi, I need to tell a checkbox list that if two of the items have been checked, to uncheck themselves. I need help! Thanks :) ~Chelimar
2
2063
by: uoziod | last post by:
Hello. Sorry for my english :) I got a next problem. This is a HTML. <ul> <li id="cat3"><input type="checkbox" onChange="javascript:groupCatCheck('3', this)" name="categories" value="3" />(3)</li>
2
2317
by: Aaron Reimann | last post by:
I have a lot of check boxes. This is an update of the check boxes, I want something was checked, then to do an insert (which is currently working), if something is no longer checked...delete the checkbox join/link that is in the database. So, the insert/checked is working, but the "unchecking" is not working. I don't know how to compare an array of what was not checked. Here is my code: if (is_array($_POST)) {
1
1851
Death Slaught
by: Death Slaught | last post by:
I play a game that when your backpack fills with items (the limit is 45) you must choose items to discard by unchecking their box. This is very annoying and time consuming so I was wondering if it were possible to create a Javascript function to be saved as a bookmark, and when used it prompts for the checkbox to start at (so it won't discard items that I want to keep) and discards all items after that point. So my main question is, is it...
0
8454
marktang
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...
0
8363
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,...
1
8561
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
8645
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...
0
7389
agi2029
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...
1
6203
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
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2776
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
2
1778
bsmnconsultancy
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...

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.