[英]How to use a value from a table in one html file in a form that is in another html file
這是用於建立一個保存產品數據的表:我希望將表的數量部分取出,並將其用作另一種形式的變量,並在另一種功能中使用它。
{{#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>
<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>
我想知道如何將數量從該函數轉換為另一個HTML文件中的該函數
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;
}
您可以將值保存在Cookie或localStorage中,以便從其他HTML頁面訪問它。
檢查此鏈接: 在多個html頁面之間共享變量
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.