2016-10-13 27 views
0

這是用於構建保存產品數據的表格:我希望表格中的數量部分出來並將其用作以另一種形式變量並在另一個函數中使用它。如何在一個HTML文件中的表格中使用另一個HTML文件中的表格中的值

{{#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> 

我想知道如何得到該函數的數量到這個函數是在另一個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; 
} 
+0

有沒有'類=「存儲的電流量」'你的HTML。 – Barmar

+0

這是另一個html函數getCurrentQuantity()所在。它是一個輸入 – MNM

+1

Javascript只能訪問當前頁面的DOM,它不能訪問另一個文件。 – Barmar

回答

相關問題