Proper syntax to use a function value in JS help

Working on a form to put on the web and I’m just trying to get some JS working. Probably an easy one for you people out there and if you could point me in the right direction that’d be great.I have a field on the form and in the HTML attributes of that field I have:

“align="right"onblur = "DateCheck(1);"”

The DateCheck() function is as follows:

function DateCheck(fieldnumber) {

var QtyEntered = document.forms[0].ProdQty[fieldnumber].value;

alert(QtyEntered);

}

And then I’m just trying to display the info in a popup window.

But I get this error:

document.forms.0.ProdQty is null or not an object

Am I passing the functions value properly using square brackets to the variable QtyEntered?

Thanks for the help

Kenny

Subject: Proper syntax to use a function value in JS help

It’s not exactly clear what you are trying to do. From your example, it appears you may have several fields that begin with “ProdQty” (i.e. ProdQty1, ProdQty2, etc) and you are trying to retrieve the value from the specific field by passing the number of the field. If so, try replacing the line that’s blowing up with

var QtyEntered = document.forms[0].elements[‘ProdQty’ + fieldnumber].value;

Hope that helps.

Subject: RE: Proper syntax to use a function value in JS help

Yes!! That’s what I was looking for. Thanks Wing

Kenny