southbeach
Programmer
I am using PHP to dynamically generate forms with hidden values. I am using names such as isBD[], isHZ[], isOV[], etc. The reason behind the naming convention is so that PHP can process the fields as arrays when form is submitted.
The form I am working on is a data grid with a single check box field per row. If a check box is clicked, I am calling
which in turn should check the values of associated array elements and set accumulative values accordingly.
I am getting errors on the line
The error tells me that "ship" is not defined. The error is correct since I named the fields "ship[]" not "ship".
What must I do to get around this problem? I mean, short of having a second set of fields excluding the square brackets.
Thank you all in advance for your assistance!
--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
The form I am working on is a data grid with a single check box field per row. If a check box is clicked, I am calling
Code:
function clicked(n)
{
isBD=document.forms[0].isBD;
isHZ=document.forms[0].isHZ;
isOV=document.forms[0].isOV;
isFUM=document.forms[0].isFUM;
pcs=document.forms[0].pcs;
wgt=document.forms[0].wgt;
vwgt=document.forms[0].vwgt;
povalue=document.forms[0].povalue;
ship=document.forms[0].ship;
totalPCS=document.getElementById('totalPCSID').value;
totalKGS=document.getElementById('totalKGSID').value;
totalVKGS=document.getElementById('totalVKGSID').value;
totalVAL=document.getElementById('totalVALID').value;
bdPCS=document.getElementById('bdPCSID').value;
ovPCS=document.getElementById('ovPCSID').value;
fumPCS=document.getElementById('hzPCSID').value;
hazPCS=document.getElementById('fumPCSID').value;
if (ship[n].checked == true) {
totalPCS=(1*totalPCS)+(1*ship[n].value);
totalKGS=(1*totalKGS)+(1*wgt[n].value);
totalVKGS=(1*totalVKGS)+(1*vwgt[n].value);
totalVAL=(1*totalVAL)+(1*povalue[n].value);
if (isBD[n].value == 'Y' || isBD[n].value == 'y') bdPCS=(1*bdPCS)+(1*ship[n].value);
if (isHZ[n].value == 'Y' || isHZ[n].value == 'y') hzPCS=(1*hzPCS)+(1*ship[n].value);
if (isOV[n].value == 'Y' || isOV[n].value == 'y') ovPCS=(1*ovPCS)+(1*ship[n].value);
if (fumBD[n].value == 'Y' || fumBD[n].value == 'y') fumPCS=(1*fumPCS)+(1*ship[n].value);
} else {
totalPCS=(1*totalPCS)-(1*ship[n].value);
totalKGS=(1*totalKGS)-(1*wgt[n].value);
totalVKGS=(1*totalVKGS)-(1*vwgt[n].value);
totalVAL=(1*totalVAL)-(1*povalue[n].value);
if (isBD[n].value == 'Y' || isBD[n].value == 'y') bdPCS=(1*bdPCS)-(1*ship[n].value);
if (isHZ[n].value == 'Y' || isHZ[n].value == 'y') hzPCS=(1*hzPCS)-(1*ship[n].value);
if (isOV[n].value == 'Y' || isOV[n].value == 'y') ovPCS=(1*ovPCS)-(1*ship[n].value);
if (fumBD[n].value == 'Y' || fumBD[n].value == 'y') fumPCS=(1*fumPCS)-(1*ship[n].value);
}
document.getElementById('totalPCSID').value=totalPCS;
document.getElementById('totalKGSID').value=totalKGS;
document.getElementById('totalVKGSID').value=totalVKGS;
document.getElementById('totalVALID').value=totalVAL;
document.getElementById('bdPCSID').value=bdPCS;
document.getElementById('ovPCSID').value=ovPCS;
document.getElementById('hzPCSID').value=hzPCS;
document.getElementById('fumPCSID').value=fumPCS;
xajax_clicked(totalPCS,totalKGS,totalVKGS,totalVAL,bdPCS,ovPCS,hzPCS,fumPCS);
}
I am getting errors on the line
Code:
if (ship[n].checked == true) {
What must I do to get around this problem? I mean, short of having a second set of fields excluding the square brackets.
Thank you all in advance for your assistance!
--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.