NEED INPUT VALUES TO MATCH ARGS ARRAY OR THROW AN ALERT
This is what I have but I want the alert to refrence the var args= or throw the alert.

function qtymultiply(qty){
var fs=qty.parentNode.parentNode;
var subtotal=document.getElementById('subtotal');
var args=[1,2,4,6,8,10,20]; //array I need to match foreach element
var multiply=0.0;
var price=fs.cells[4].innerHTML;
var quantity=fs.cells[5].getElementsByTagName('input')[0].value; 
var cost=fs.cells[6];
var rowsubtotal=fs.cells[7];
if(qty.value!=''||qty.value!=0){ //qty.value '0' not throwing alert? Need to match args elements
multiply+=price*quantity;
cost.innerHTML=parseFloat(multiply).toFixed(2);
sumsubtotal();
rowsubtotal.innerHTML=subtotal.innerHTML;
}
else {
alert('You only have these options: 1,2,4,6,8,10 or 20');
qty.focus;
}
}

Any help would be :cool:

Solved!!
Thanks to Andrew_g at About.com Javascript Forum. Thanks bud, you Rock! :pretty::cool:

function itemrowMultiply() {
var aObj=document.getElementsByClassName('qty');
for(var i=0; i<aObj.length; i++) {
    aObj[i].onchange=function() {qtymultiply(this);};
    }
};

function qtymultiply(qty){
    var fs=qty.parentNode.parentNode;
    var subtotal=document.getElementById('subtotal');
    var args=[1, 2, 4, 6, 8, 10, 20];
    var multiply=0.0;
    var price=fs.cells[4].innerHTML;
    var quantity=fs.cells[5].getElementsByTagName('input')[0].value;
    var cost=fs.cells[6];
    var rowsubtotal=fs.cells[7];

    for(var i=0; i !==args.length; i++) {
        if(qty.value ==args[i]){
            multiply+=price*quantity;
            cost.innerHTML=parseFloat(multiply).toFixed(2);
            sumsubtotal();
            rowsubtotal.innerHTML=subtotal.innerHTML;

            return; // exit loop and function.
        }
    }
  
// This should only run if the statements in the if statement nested in the for loop do not execute.

    alert('You only have these options: 1, 2, 4, 6, 8, 10 or 20         ');
    qty.focus;
    cost.innerHTML='0';
    qty.value='?';
    sumsubtotal();
}

:(:'(Can anybody tell me how to mark posts as 'Solved'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.