0

This is for building a table that holds data for products: I want the quantity part of the table out and use it as a variable in another form and use it in another function.

{{#viewTableData}}
<tr class="view-product-row">
<td class="product-name" data-product-id="{{ id }}">{{ name }}</td>
<td class="product-maker-number" data-product-id="{{ id }}">{{ makerNumber }}</td>
<td class="product-jan-code" data-product-id="{{ id }}">{{ janCode }}</td>
<td class="product-current-quantity">{{ quantity }}</td>
<td style="text-align: center">
    <button type="button" class="btn btn-info edit-current-quantity-button" data-toggle="modal" data-target="#edit-current-quantity-modal"><span class="glyphicon glyphicon-pencil"></span></button>
        &nbsp;&nbsp;&nbsp;
    <button type="button" class="btn btn-success new-movement-button" data-toggle="modal" data-target="#movement-modal"><span class="glyphicon glyphicon-plus"></span></button>
</td>
</tr>
 {{/viewTableData}}

 {{^viewTableData}}
 <tr>
<td colspan="5">
    {{#i18n}}inventory.view.no-data{{/i18n}}
</td>
</tr>
{{/viewTableData}}
<script>
$(document).ready(function() {
    $('.edit-current-quantity-button').on('click', function() {populateEditCurrentQuantityModal(this)});
    $('.new-movement-button').on('click', function() {populateNewMovementModalFromView(this)});
});
</script>

I want to know how to get quantity from that function into this function that is in another html file

function getCurrentQuantity()
{
    //find the item and the store and get the quantity
    //get data from the database
    //Use store id and jan code for the query 
    //That way both get updated when either is changed
    //product-jan-code and store-from

    var q = $(".store-from-current-quantity").val(); // this does not work this is the input where the quantity from the other class should go


    //update the UI if it is not done auto
    fromStoreCurrentQuantity.value = q;
    return q;
}
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
MNM
  • 2,673
  • 6
  • 38
  • 73

1 Answers1

1

You can save the value in Cookie or localStorage in order to access it from other HTML page.

Check this link: Sharing a variable between multiple html pages

Community
  • 1
  • 1
AshishJindal
  • 176
  • 2
  • 10