How i can get value of specific cell if row is checked?

ermanno.tedeschi

I have an HTML table. I need to get specific cell value if column is checked! For each row I have a checkBox.

<table id="tabellaOrdinaFarmaci" class="table table-striped table-bordered" cellspacing="0" width="100%">
            <thead>
                <tr>
                    <th>Codice Farmaco</th>
                    <th>Nome Farmaco</th>
                    <th>Quantità </th>
                    <th>Quantità di alert</th>
                    <th>Stato</th>
                    <th>Quantità da ordinare</th>
                    <th></th>
                </tr>
            </thead>
        </thead>
        <tbody>
            <?php
            foreach ($query as $row):
                $quantitaDaOrdinare = $row->alert - $row->quantita;
                if ($quantitaDaOrdinare > 0) {
                    ?>
                    <tr id="<?php echo $row->aic; ?>" > 
                        <td ><?php echo $row->aic; ?></td>
                        <td name="nomeFarmac"o><?php echo $row->denominazione ?></td>
                        <td><?php echo $row->quantita; ?></td>
                        <td><?php echo $row->alert; ?></td>
                        <td><?php echo $row->stato; ?></td>
                        <td>
                            <input type="text" class="form-control auto" name="codiceFarmaco" value="<?php echo $quantitaDaOrdinare ?>"/>
                        </td>
                        <td>   <label>
                                <input type="checkbox" name="checkBox" value="<?php echo$row->aic; ?> ">
                            </label></td>
                    </tr>
                    <?php
                } else {

                }
            endforeach;
            ?>
        </tbody>

I need (using javascript or jquery) to get, if a button is clicked, every value of cell that have name="nomeFarmaco" for every row that is checked! I try to call this function whe

function getValue(){
     var nome = $('input[name="checkBox"]:checked').map(function() {
                            return $(this).parent().parent().parent().find('name="nomeFarmaco').val();
                        }).get();
return nome;}

but nome is an empty array! any ideas? thanks in advance!

Suman Biswas

You can put a custom attribute for the check box and set the value in this attribute. Like this :

<input type="checkbox" name="checkBox" value="<?php echo$row->aic; ?> " customattr="<?php echo $row->denominazione ?>">

And you javascript function will be :

function getValue(){
    var nome = $('input[name="checkBox"]:checked').attr('customattr');
    return nome;
  }

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I get the value of a label in a cell

From Dev

How can I get the value of an input in a specific table cell using javascript?

From Dev

How can I get the value of an input in a specific table cell using javascript?

From Dev

How can I retrieve a specific cell value from another Excel sheet using this complex logic that find the row using another value?

From Dev

How can i get attribute value from a checkbox if it's checked?

From Dev

How can i keep the radio button checked and get the value

From Dev

how to check if a row is checked and a specific cell is empty using jquery?

From Dev

How can I reference a row in another sheet based on value in cell?

From Dev

DataTables - How do I get/set the value of a cell in a row?

From Dev

A cell contains the number of row and I want to get the value of that row on specific column

From Dev

How can I delete every cell with a specific value in excel vba?

From Dev

How can I only count cells if a different cell is a specific value?

From Dev

How can I delete every cell with a specific value in excel vba?

From Dev

How can I get the specific element value

From Dev

How to get the first row corresponding cell value if i change the other rows cell value in kendo child grid

From Dev

how can I get the row of value that also occurred in other row?

From Dev

Get particular cell value for each checked row when header check box checked

From Dev

How i can get the value of cell in datagrid in wpf?

From Dev

How can I get the value of a cell that is colored red?

From Dev

How can I get the address of xlsx cell containing provided value?

From Dev

In python, how can I search a specific column for a specific value in a txt file then return the specific value's row?

From Dev

How can I find all cell references in a row that contain a value, and display them in one cell?

From Dev

SQL - how to get specific value of cell?

From Dev

Google apps script - Get row number of a cell containing specific value

From Dev

Get row from a table by td class and specific value in the cell in jquery

From Dev

How can I get the selected row's value of a qtablewidget in PyQt?

From Dev

How can I get a specific value from an array for my object?

From Dev

how can i get a specific value based on different criteria with vlookup?

From Dev

How can i change color of particular row in datagridview, where a cell value is first timestamp of each day?

Related Related

  1. 1

    How can I get the value of a label in a cell

  2. 2

    How can I get the value of an input in a specific table cell using javascript?

  3. 3

    How can I get the value of an input in a specific table cell using javascript?

  4. 4

    How can I retrieve a specific cell value from another Excel sheet using this complex logic that find the row using another value?

  5. 5

    How can i get attribute value from a checkbox if it's checked?

  6. 6

    How can i keep the radio button checked and get the value

  7. 7

    how to check if a row is checked and a specific cell is empty using jquery?

  8. 8

    How can I reference a row in another sheet based on value in cell?

  9. 9

    DataTables - How do I get/set the value of a cell in a row?

  10. 10

    A cell contains the number of row and I want to get the value of that row on specific column

  11. 11

    How can I delete every cell with a specific value in excel vba?

  12. 12

    How can I only count cells if a different cell is a specific value?

  13. 13

    How can I delete every cell with a specific value in excel vba?

  14. 14

    How can I get the specific element value

  15. 15

    How to get the first row corresponding cell value if i change the other rows cell value in kendo child grid

  16. 16

    how can I get the row of value that also occurred in other row?

  17. 17

    Get particular cell value for each checked row when header check box checked

  18. 18

    How i can get the value of cell in datagrid in wpf?

  19. 19

    How can I get the value of a cell that is colored red?

  20. 20

    How can I get the address of xlsx cell containing provided value?

  21. 21

    In python, how can I search a specific column for a specific value in a txt file then return the specific value's row?

  22. 22

    How can I find all cell references in a row that contain a value, and display them in one cell?

  23. 23

    SQL - how to get specific value of cell?

  24. 24

    Google apps script - Get row number of a cell containing specific value

  25. 25

    Get row from a table by td class and specific value in the cell in jquery

  26. 26

    How can I get the selected row's value of a qtablewidget in PyQt?

  27. 27

    How can I get a specific value from an array for my object?

  28. 28

    how can i get a specific value based on different criteria with vlookup?

  29. 29

    How can i change color of particular row in datagridview, where a cell value is first timestamp of each day?

HotTag

Archive