I actually got it to work using the code below.Thanks to all who gave me their inputs, but have to say I had difficulties getting it to work properly. Hope it will be helpful to somebody else who is new in javascript.
function SelectedRow() {
(function () {
if (window.addEventListener) {
window.addEventListener('load', run, false);
} else if (window.attachEvent) {
window.attachEvent('onload', run);
}
function run() {
var table = document.getElementById('alternativeCableTable');
table.onclick = function (event) {
var target = event.target || event.srcElement;
while (target && target.nodeName != 'TR') {
target = target.parentElement;
}
var cells = target.cells;
if (!cells.length || target.parentNode.nodeName == 'THEAD') {
return;
}
var stockcode = document.getElementById('stockcode');
var wiretype = document.getElementById('wiretype');
var wirelength = document.getElementById('wirelength');
var terminalA = document.getElementById('termA');
var sealA = document.getElementById('sealA');
var terminalB = document.getElementById('termB');
var sealB = document.getElementById('sealB');
stockcode.value = cells[0].innerHTML;
wiretype.value = cells[1].innerHTML;
wirelength.value = cells[2].innerHTML;
terminalA.value = cells[3].innerHTML;
sealA.value = cells[4].innerHTML;
terminalB.value = cells[5].innerHTML;
sealB.value = cells[6].innerHTML;
alert("The select data is sent to print page");
window.open("http://10.19.13.67/ReworkLabels/PrintLabelPage.aspx?stockcode=" + decodeURIComponent(stockcode.value) + "&wiretype=" + decodeURIComponent(wiretype.value) + "&wirelength=" + decodeURIComponent(wirelength.value)
+ "&terminalA=" + decodeURIComponent(terminalA.value) + "&sealA=" + decodeURIComponent(sealA.value) + "&terminalB=" + decodeURIComponent(terminalB.value) + "&sealB=" + decodeURIComponent(sealB.value),"_blank");
};
}
})();
}