amethystct
Programmer
I have a js function for a checkbox. It's on every row of my part detail so I could have 1 - ? rows If I have more than 1 rows then the checkbox works correctly. When a user checks it I open a new page. If, however, I only have 1 row then I get an error that the value doesn't exist. Why does this happen?
This is the function. If I have only one row and I set the first field (aoms) to document.varViewPost.aoms.value then it's fine. I can't do this set if there are more than 1 rows returned though. I should still have an array of results even if it's only 1 row returned right??
function showInfo (infoObj){
var rowIndex = infoObj.name;
var formObj = document.varViewPost;
var custpo = formObj.custpo[rowIndex].value;
custpo = custpo.replace(/\W+$/,'');
var aoms = formObj.aoms[rowIndex].value;
aoms = aoms.replace(/\W+$/,'');
var partnum = formObj.partnum[rowIndex].value;
partnum = partnum.replace(/\W+$/,'');
var custCode = document.varViewPost.custcode.value;
custCode = custCode.replace(/\W+$/,'');
var contract = document.varViewPost.contract.value;
contract = contract.replace(/\W+$/,'');
var ordernum = document.varViewPost.ordernum.value;
ordernum = ordernum.replace(/\W+$/,'');
var windowwidth = 800, topheight = 600, bottomheight = 10; // default sizes
if (window.screen) {
windowwidth = window.screen.availWidth-10;
topheight = (window.screen.availHeight * 60 / 100) - 10;
bottomheight = (window.screen.availHeight * 40 / 100) - 20;
}
var UHJ = 'contractInfo.jhtml?orderNum=' + ordernum + '&custCode=' + custCode + '&AOMS=' + aoms + '&CUSTPO=' + custpo + '&PRODCODE=' + partnum;
infoObj.checked = false;
window.open(UHJ,'test','scrollbars=yes');
}
function call:
<INPUT TYPE="HIDDEN" NAME="indexVal" VALUE="0">
<INPUT TYPE="HIDDEN" NAME="rowCount" VALUE="1">
<INPUT TYPE="HIDDEN" NAME="aoms" value="3849004">
<INPUT TYPE="HIDDEN" NAME="custpo" value="3034-0125-7800">
<INPUT TYPE="HIDDEN" NAME="partnum" value="TE-6311P-1">
<INPUT TYPE="HIDDEN" NAME="login" value="taylork">
<INPUT TYPE="HIDDEN" NAME="email" value="ktaylor@usco.com">
<TD>1</TD>
<TD>3849004</TD>
<TD>3034-0125-7800</TD>
<TD>TE-6311P-1</TD>
<TD>TEMP SENSOR; 1000 OHM, NI</TD>
<TD ALIGN="CENTER">50</TD>
<TD ALIGN="CENTER">50</TD>
<TD ALIGN="CENTER">
<INPUT TYPE="checkbox" NAME="0" VALUE="moreInfo" onClick="showInfo(this);">
</TD>
This is the function. If I have only one row and I set the first field (aoms) to document.varViewPost.aoms.value then it's fine. I can't do this set if there are more than 1 rows returned though. I should still have an array of results even if it's only 1 row returned right??
function showInfo (infoObj){
var rowIndex = infoObj.name;
var formObj = document.varViewPost;
var custpo = formObj.custpo[rowIndex].value;
custpo = custpo.replace(/\W+$/,'');
var aoms = formObj.aoms[rowIndex].value;
aoms = aoms.replace(/\W+$/,'');
var partnum = formObj.partnum[rowIndex].value;
partnum = partnum.replace(/\W+$/,'');
var custCode = document.varViewPost.custcode.value;
custCode = custCode.replace(/\W+$/,'');
var contract = document.varViewPost.contract.value;
contract = contract.replace(/\W+$/,'');
var ordernum = document.varViewPost.ordernum.value;
ordernum = ordernum.replace(/\W+$/,'');
var windowwidth = 800, topheight = 600, bottomheight = 10; // default sizes
if (window.screen) {
windowwidth = window.screen.availWidth-10;
topheight = (window.screen.availHeight * 60 / 100) - 10;
bottomheight = (window.screen.availHeight * 40 / 100) - 20;
}
var UHJ = 'contractInfo.jhtml?orderNum=' + ordernum + '&custCode=' + custCode + '&AOMS=' + aoms + '&CUSTPO=' + custpo + '&PRODCODE=' + partnum;
infoObj.checked = false;
window.open(UHJ,'test','scrollbars=yes');
}
function call:
<INPUT TYPE="HIDDEN" NAME="indexVal" VALUE="0">
<INPUT TYPE="HIDDEN" NAME="rowCount" VALUE="1">
<INPUT TYPE="HIDDEN" NAME="aoms" value="3849004">
<INPUT TYPE="HIDDEN" NAME="custpo" value="3034-0125-7800">
<INPUT TYPE="HIDDEN" NAME="partnum" value="TE-6311P-1">
<INPUT TYPE="HIDDEN" NAME="login" value="taylork">
<INPUT TYPE="HIDDEN" NAME="email" value="ktaylor@usco.com">
<TD>1</TD>
<TD>3849004</TD>
<TD>3034-0125-7800</TD>
<TD>TE-6311P-1</TD>
<TD>TEMP SENSOR; 1000 OHM, NI</TD>
<TD ALIGN="CENTER">50</TD>
<TD ALIGN="CENTER">50</TD>
<TD ALIGN="CENTER">
<INPUT TYPE="checkbox" NAME="0" VALUE="moreInfo" onClick="showInfo(this);">
</TD>