473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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,eventhough 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 CheckChangedEvent(ctrl1,ctrl2)
{
var ctrlID1=document.getElementById(ctrl1);
var ctrlID2=document.getElementById(ctrl2);
ctrlID2.checked = true;
if(ctrlID1.checked == true)
{
ctrlID2.checked = true;
ctrlID2.disabled = true;
}
else if(ctrlID1.checked == false)
{
ctrlID2.checked = false;
ctrlID2.disabled = false;
}
}

and in server side am getting the value as follows.
ViewState["id_Modify_chk"] =
Convert.ToInt32(((HtmlInputCheckBox)dg1.Cells[2].FindControl("_gridChkModify")).Checked);
ViewState["id_View_chk"] =
Convert.ToInt32(((HtmlInputCheckBox)dg1.Cells[3].FindControl("_gridChkView")).Checked);
int _modi_val = Convert.ToInt32(ViewState["id_Modify_chk"]);
int _view_val = Convert.ToInt32(ViewState["id_View_chk"]);

Thanks and Regards,
N.Ramakrishnan
Nov 21 '05 #1
1 5879
"Ramakrishnan Nagarajan" <ra**********@discussions.microsoft.com> schrieb:
and in server side am getting the value as follows.
ViewState["id_Modify_chk"] =
Convert.ToInt32(((HtmlInputCheckBox)dg1.Cells[2].FindControl("_gridChkModify")).Checked);
ViewState["id_View_chk"] =
Convert.ToInt32(((HtmlInputCheckBox)dg1.Cells[3].FindControl("_gridChkView")).Checked);
int _modi_val = Convert.ToInt32(ViewState["id_Modify_chk"]);
int _view_val = Convert.ToInt32(ViewState["id_View_chk"]);


ASP.NET-related questions will more likely get answered in one of the groups
inthe microsoft.public.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
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...
3
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...
12
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...
0
by: Pat Roy | last post by:
Hello... I've created a treeview that looks something like: Root .....Folder1 .........Subfolder1A .............File .............File .........Subfolder1B
2
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...
2
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
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"...
2
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...
1
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...

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.