How to check if one value is greater than other

vladimir

I have some problems with this checking in jQuery.

Problem:

I have dynamically generated table. In this table I have many rows. In each row I have checkbox and input. If input is not empty then checkbox checked automatically on input blur.

e.g. I have two filled inputs with some values and checkboxes are checked also. I want to check if the input value is greater then some value.

Code:

$("#btn_send_order")
  .on("click", function(){

  var keys = new Array(),
      array = new Array();

  $(':checkbox[class="send_vacc checkbox"]:checked').each (function() 
  {
    if ( parseInt($("input[id='"+this.id+"'].sended_cnt").val()) > parseInt($("input[id='"+this.id+"'].sended_cnt").attr("class").split(" ")[2]) )
    {
      return false;
    }
    else
    {
      array.push( $("input[id='"+this.id+"'].sended_cnt").val() );
      keys.push( this.id );
    }
  });
});

So, I have a value which is entered into input and second value I get from its class which is formed from a php script.

Code above only works if the first input has greater value then its class value (I test this code on two rows table)

<tbody>
    <tr style="text-align: center; background-color: pink;" class="rek888889" id="76">
        <td>1</td>
        <td>ser5555778</td>
        <td>test_vaccine98</td>
        <td>74 / <input type="text" id="76" name="sended_cnt" class="sended_cnt rek888889 74" maxlength="3"></td>
        <td>31.10.2026</td>
        <td>rek888889</td>
        <td><input class="send_vacc checkbox" id="76" type="checkbox"></td>
    </tr>
    <tr style="text-align: center; background-color: pink;" class="rek123" id="1">
        <td>2</td>
        <td>ser1098</td>
        <td>test_vaccine_1</td>
        <td>600 / <input type="text" id="1" name="sended_cnt" class="sended_cnt rek123 600" maxlength="3"></td>
        <td>13.10.2025</td>
        <td>rek123</td>
        <td><input class="send_vacc checkbox" id="1" type="checkbox"></td>
    </tr>
</tbody>

How can I change this code to check all the values?

Ergec

You can't have same ID more than once in your code. So checkbox and input IDs must be different. I renamed input IDs to inputXX . Also you could write your selectors in much better ways.

fiddle

https://jsfiddle.net/ergec/juney6mq/

snippet

$("#btn_send_order").on("click", function() {
    var keys = new Array(),
        array = new Array();
    $('.send_vacc.checkbox:checked').each(function() {
        if (parseInt($("input[id='input" + this.id + "'].sended_cnt").val()) > parseInt($("input[id='input" + this.id + "'].sended_cnt").attr("class").split(" ")[2])) {
            return false;
        } else {
            array.push($("input[id='input" + this.id + "'].sended_cnt").val());
            keys.push(this.id);
        }
    });
	console.log(keys);
	console.log(array);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<table>
    <tbody>
        <tr style="text-align: center; background-color: pink;" class="rek888889" id="76">
            <td>1</td>
            <td>ser5555778</td>
            <td>test_vaccine98</td>
            <td>74 /
                <input type="text" id="input76" name="sended_cnt" class="sended_cnt rek888889 74" maxlength="3">
            </td>
            <td>31.10.2026</td>
            <td>rek888889</td>
            <td>
                <input class="send_vacc checkbox" id="76" type="checkbox">
            </td>
        </tr>
        <tr style="text-align: center; background-color: pink;" class="rek123" id="1">
            <td>2</td>
            <td>ser1098</td>
            <td>test_vaccine_1</td>
            <td>600 /
                <input type="text" id="input1" name="sended_cnt" class="sended_cnt rek123 600" maxlength="3">
            </td>
            <td>13.10.2025</td>
            <td>rek123</td>
            <td>
                <input class="send_vacc checkbox" id="1" type="checkbox">
            </td>
        </tr>
    </tbody>
</table>
<button id="btn_send_order">Send Order
</button>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Check if value of array is greater than. Than do other styling

From Dev

How to check if a value is greater than or equal to another?

From Dev

Echo error message if one input value is greater than other in php

From Dev

Check if a pandas Series has at least one item greater than a value

From Dev

How can I check if a date is greater than the other?

From Dev

how to check an array if each following value is greater than the last

From Dev

Javascript how to check if a date is greater than or equal to a date value

From Dev

Javascript how to check if a date is greater than or equal to a date value

From Dev

How to check version is greater than some base value?

From Dev

How to check if value is greater than another using javascript

From Dev

How to check value of input is greater than 12 in jquery using if statement

From Dev

Aurelia validate one datetime is greater than the other

From Dev

Conditional Formatting if one time is greater than the other

From Dev

Check if variables are one greater than the previous in batch?

From Dev

Python : How to find in set of rows, one element is less than 1 and other is greater than 1?

From Dev

Python : How to find in set of rows, one element is less than 1 and other is greater than 1?

From Dev

Check if map key greater than value

From Dev

Check if map key greater than value

From Dev

How to check if value is bigger than each other value?

From Java

How to create a cumulative sum column in python if column value is greater than other value

From Java

How to check if a date is greater than another in Java?

From Dev

How do I create a query with greater than one date and not between some other dates?

From Dev

How to check that all elements of one array are greater than their counterparts in a parallel array (in Ruby).

From Dev

Javascript roundup decimal values if decimal value is greater than or equal to 25 then round up value by plus one other wise remain as it is

From Dev

PHP Carbon Check If Chosen Date is Greater than Other Date

From Dev

How to write an if statement to check whether any item in array is greater than a specific value/date?

From Dev

How to check if any item in a list of integers has a value greater than the length of the list

From Dev

Realm check if value of first column greater than value of second column

From Dev

Checking if one date is greater than the other using Google Script

Related Related

  1. 1

    Check if value of array is greater than. Than do other styling

  2. 2

    How to check if a value is greater than or equal to another?

  3. 3

    Echo error message if one input value is greater than other in php

  4. 4

    Check if a pandas Series has at least one item greater than a value

  5. 5

    How can I check if a date is greater than the other?

  6. 6

    how to check an array if each following value is greater than the last

  7. 7

    Javascript how to check if a date is greater than or equal to a date value

  8. 8

    Javascript how to check if a date is greater than or equal to a date value

  9. 9

    How to check version is greater than some base value?

  10. 10

    How to check if value is greater than another using javascript

  11. 11

    How to check value of input is greater than 12 in jquery using if statement

  12. 12

    Aurelia validate one datetime is greater than the other

  13. 13

    Conditional Formatting if one time is greater than the other

  14. 14

    Check if variables are one greater than the previous in batch?

  15. 15

    Python : How to find in set of rows, one element is less than 1 and other is greater than 1?

  16. 16

    Python : How to find in set of rows, one element is less than 1 and other is greater than 1?

  17. 17

    Check if map key greater than value

  18. 18

    Check if map key greater than value

  19. 19

    How to check if value is bigger than each other value?

  20. 20

    How to create a cumulative sum column in python if column value is greater than other value

  21. 21

    How to check if a date is greater than another in Java?

  22. 22

    How do I create a query with greater than one date and not between some other dates?

  23. 23

    How to check that all elements of one array are greater than their counterparts in a parallel array (in Ruby).

  24. 24

    Javascript roundup decimal values if decimal value is greater than or equal to 25 then round up value by plus one other wise remain as it is

  25. 25

    PHP Carbon Check If Chosen Date is Greater than Other Date

  26. 26

    How to write an if statement to check whether any item in array is greater than a specific value/date?

  27. 27

    How to check if any item in a list of integers has a value greater than the length of the list

  28. 28

    Realm check if value of first column greater than value of second column

  29. 29

    Checking if one date is greater than the other using Google Script

HotTag

Archive