Function if inArray, display text, else display other text....not working

Function if inArray, display text, else display other text....not working

Hello there!

I have this html containing an input with name "product_id":

  1. <form method="post" class="form-horizontal" onsubmit="return check_add_to_cart(this, false) " enctype="multipart/form-data" id="productDetailsAddToCartForm">
  2.       <input type="hidden" name="action" value="add">
  3.        <input type="hidden" name="product_id" value="167">                
  4.        <input type="hidden" name="variation_id" class="CartVariationId" value="">                 
  5.         <div class="ProductDetailsGrid ProductAddToCart" id="ProductDetailsAddToCart"> 
  6.              bunch of other irrelevant code....
  7.         </div>
  8. </form>




What I need to do is display "No Local Delivery" in span #shippingDetails if the value of input with name=product_id is in an array of numbers. Otherwise, if the number is not in the array, it should display "Local Delivery Available".

I have this:

  1. var noLocal = ["167, 155"];
        if ($.inArray($("[name='product_id']").val(), noLocal) >=0) {
            $('#shippingDetails').text("No Local Delivery"); 
        } else {
            $("#shippingDetails").text("Local Delivery Available");    
        }





Something isn't right obviously because it doesn't seem to be getting the value of name='product_id'. It just displays "Local Delivery Available" all the time, no matter what the value is.

Thank you in advance!!
Susan