![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jan 2005
Posts: 6
Rep Power: 0
![]() |
javascript: retrieve datagrid checked items in confirm box
Experts,
i have a datagrid with 2 template columns,checkbox[databound] and label control. The user can check multiple checkboxes in the datagrid and click on the "Add" button to add the checked items. My problem is the client-side validation. I need the user to confirm the addition of checked items.so,i need to display a pop-up window which will ask the user "Are you sure you want to add the following items?" and below must be a list of all checked items i.e.,the text of databound template? Please guide me ..this is really important!! Thanks! |
|
|
|
|
|
#2 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
Firstly you want to catch the event that is fired before the forum is submitted. To do that, in your submit button add an onsubmit handler that calls a function:
<form id="form1"> <input type="checkbox" ... <input type="submit" onsubmit="return validateData()" /> </input> function validateData() {
form = document.getElementById("form1");
// Loop through all of the input elements in the form..
for(var i = 0; i < form.elements.length; ++i) {
// If the element is a checkbox, and it is checked
if(i.getAttribute("type") == "checkbox" && i.checked) {
// Then add this checkbox to a list or whatever.
}
}
return confirm("Are you sure you want to ...")
} |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Jan 2005
Posts: 6
Rep Power: 0
![]() |
But, how can i append the confirm message with the text of checked items which are databound...??? Do i use innerText of checkbox control to retrieve the text of checked items and put it in a variable and then concatenate it to the confirm message??
|
|
|
|
|
|
#4 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
How are the checkboxes and text mapped to each other? Via label elements with the for attribute set to the ID of the corresponding checkbox?
|
|
|
|
|
|
#5 |
|
Newbie
Join Date: Jan 2005
Posts: 6
Rep Power: 0
![]() |
not label...but used container.databind...to the dataset
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|