Hi All,
What i want to do is - I have a grid view and in that there are check box and a hyperlink to another form in each row. I need to select multiple check box and hit on Print Button. It should print all the forms (linked by hyperlink) with same url but different parameters.
Problem is that i have written the code which is working fine but sometimes it behaves very uncertain. When i check few check boxes, let say 5; 5 new windows are opened but sometimes same window is loaded with new url and print command comes only for 3 windows and skips for the other two overridden.
function PrintForm(dataGridView) {
var objSearch = document.getElementById(dataGridView);
var ControlId = '';
var txtAppend = '';
var hidReqid = '';
var txtReqId = '';
if(objSearch) {
var objSearchRows = objSearch.rows.length; }
//Loop thru the grid rows and check for the checked checkboxes
for ( var rowCount = 2; rowCount < objSearchRows + 1; rowCount++ ) {
if(rowCount < 10) {
txtAppend = '_ctl0'; }
else {
txtAppend = '_ctl'; }
ControlId = objSearch.id + txtAppend + rowCount + '_chkSelect';
ControlId = document.getElementById(ControlId);
if(ControlId) {
if(ControlId.checked == true) {
hidReqid = objSearch.id + txtAppend + rowCount + '_hidRqstId';
txtReqId = document.getElementById(hidReqid).value;
var mywindow = window.open('PrintForm.aspx?RqstId='+txtReqId,'RequestForm'+txtReqId,"toolbar=no,resizable=yes, scrollbars=yes,menubar=no, location=no, height=30, width=30");
window.focus();
mywindow.print();
mywindow.close();
}
}
}
}
What i want to do is - I have a grid view and in that there are check box and a hyperlink to another form in each row. I need to select multiple check box and hit on Print Button. It should print all the forms (linked by hyperlink) with same url but different parameters.
Problem is that i have written the code which is working fine but sometimes it behaves very uncertain. When i check few check boxes, let say 5; 5 new windows are opened but sometimes same window is loaded with new url and print command comes only for 3 windows and skips for the other two overridden.
function PrintForm(dataGridView) {
var objSearch = document.getElementById(dataGridView);
var ControlId = '';
var txtAppend = '';
var hidReqid = '';
var txtReqId = '';
if(objSearch) {
var objSearchRows = objSearch.rows.length; }
//Loop thru the grid rows and check for the checked checkboxes
for ( var rowCount = 2; rowCount < objSearchRows + 1; rowCount++ ) {
if(rowCount < 10) {
txtAppend = '_ctl0'; }
else {
txtAppend = '_ctl'; }
ControlId = objSearch.id + txtAppend + rowCount + '_chkSelect';
ControlId = document.getElementById(ControlId);
if(ControlId) {
if(ControlId.checked == true) {
hidReqid = objSearch.id + txtAppend + rowCount + '_hidRqstId';
txtReqId = document.getElementById(hidReqid).value;
var mywindow = window.open('PrintForm.aspx?RqstId='+txtReqId,'RequestForm'+txtReqId,"toolbar=no,resizable=yes, scrollbars=yes,menubar=no, location=no, height=30, width=30");
window.focus();
mywindow.print();
mywindow.close();
}
}
}
}