SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Dec 2007
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Comparing table columns

    Hello,
    I have a material table wich contains the article number, a quantity input field, a max quantity field... How can i test that the input quantity is less than the max quant one ?
    Here is a sample code :
    Code:
    <table id = "visu-table">
        <tr>
            <th>Article N.</th>
            <th>Article descr.</th>
            <th>Art. Quant COL</th>
            <th>Quality</th>
            <th>Comments</th>
        </tr>
    <%
      sort palettes.
      cpt = 0.
      Describe table palettes lines sizePalettes.
      loop at palettes_out into wa_pal.
      SHIFT wa_pal-matnr LEFT DELETING LEADING '0'.
      cpt = cpt + 1.
    %>
    <tr>
            <td>&nbsp<input class="gris" type="text" name="matnr" value="<%= wa_pal-matnr%>" size=5 maxlength=18 onFocus="return clifirst()"></td>
            <td><input class="gris" type="text" name="maktx" value="<%= wa_pal-maktx%>" size=40 maxlength=40 ></td>
            <td>&nbsp<input type="text" id = "qtePal<%=cpt%>" name="qtePal" size=8 MAXLENGTH=8 value=""></td>
            <td>
                <select name="qual">
                    <option value = "No info">No info</option>
                    <option value = "Good">Good</option>
                    <option value = "Average">Average</option>
                    <option value = "bad">Bad</option>
                </select>
            </td>
            <td>&nbsp<input type="text" id="comm<%=cpt%>" name="comm" size=20 MAXLENGTH=30 value=""></td>
            <td>&nbsp<input type="hidden" id="qtColl<%=cpt%>" name="qtColl" size=20 MAXLENGTH=30 value="<%= wa_pal-zqtpal%>"></td>
    </tr>
    <%
      endloop.
    %>
    Thank you.

  2. #2
    SitePoint Enthusiast
    Join Date
    Dec 2007
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You want to check this serverside
    Mashups, DOM Scripting and all the things we call Web2.0 blogger
    http://www.heavyweightgeek.org/
    http://twitter.com/heavyweightgeek

  3. #3
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,702
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    I presume that qtePal is the quantity you wish to check against qtColl

    You really should check this serverside, because there's no guarantee that javascript will be running and that the condition will be met.
    Get the ASP working to check against such a possibility, then use javascript to help prevent the user from such difficulties.

    You can have a very simple function that compares the quantity against qtColl.

    Code ASP:
    <input type="text" id="qtePal<%=cpt%>" name="qtePal" size=8 MAXLENGTH=8 value="" onchange="checkQuantity(this, <%= wa_pal-zqtpal%>)">

    The following function would be in js/script.js or somewhere similar.

    Code JavaScript:
    function checkQuantity(el, var2) {
      console.log(el);
      if (el.value > var2) {
        alert('The maximum quantity is ' + var2);
        el.value = '';
    	return false;
      }
      return true;
    }


Bookmarks

Posting Permissions

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