www.webdeveloper.com
Results 1 to 2 of 2

Thread: javascript - input values

Hybrid View

  1. #1
    Join Date
    Jun 2012
    Posts
    9

    javascript - input values

    hi all
    i'm trying to check the dynamic values of an input field and change it if the value is over a certain amount.
    This is the script i'm using (this works fine for a single input value, but i need it to work where the input value/s are in a loop).

    Code:
    <script>
      function handleChange(input) {
        if (input.value < 0) input.value = 0;
        if (input.value > <%= FormatNumber((RSStockLevel.Fields.Item("InStock").Value)-(RSStockLevel.Fields.Item("NumberSold").Value), 0, -2, -2, -2)- objCart.GetCartValue("Quantity",i) %>) input.value = <%= FormatNumber((RSStockLevel.Fields.Item("InStock").Value)-(RSStockLevel.Fields.Item("NumberSold").Value), 0, -2, -2, -2)- objCart.GetCartValue("Quantity",i) %>;
      }
    </script>
    and for the input values (remember this code is in a loop (repeated depending on the number of records found))

    Code:
    <input name="<%="Qty" & objCart.GetCartValue("Key",i)%>" type="text" class="cartcontent" value="<%=objCart.GetCartValue("Quantity",i)%>" onchange="handleChange(this);" size="4" maxlength="2" />
    Hope someone can advise

    Thanks in advance
    Andy

  2. #2
    Join Date
    Jun 2012
    Posts
    9
    no replies yet...
    I'll try to explain better.
    I'm coding in Classic ASP
    On my shopping cart page i have a list of products that are in my basket.
    Each product line quantity 'input', can be changed if required, but i need to restrict the input value to the number of products in stock.


    I have the stock value for each product line, but because the shopping cart page 'loops' through all products in the basket, i don't know how to apply the javascript code above so that it checks the input value for each product line and restricts the input value to the stock level.
    please see attached screengrab

    Thanks again
    Andy

    basket.gif

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles