PC Review


Reply
Thread Tools Rate Thread

checking and Unchecking checkbox using Javascript

 
 
=?Utf-8?B?UmFtYWtyaXNobmFuIE5hZ2FyYWphbg==?=
Guest
Posts: n/a
 
      25th Aug 2005
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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking and Unchecking CheckBoxes in code Ayo Microsoft Excel Misc 0 3rd Apr 2009 08:41 PM
deleted items checkbox unchecking itself Joe Microsoft Outlook Discussion 0 2nd Apr 2008 02:48 PM
Unchecking checkbox Amateur Microsoft Access 3 3rd Mar 2008 04:43 PM
vb.net form checkbox not checking/unchecking on first click =?Utf-8?B?bWVnYW5fYw==?= Microsoft Dot NET 0 16th Jan 2006 06:47 PM
What is the code for checking or unchecking a checkbox? Dave R. Microsoft Access Macros 2 17th Jun 2005 07:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:15 PM.