仅为所选项目调用API

时间:2018-02-22 12:54:30

标签: javascript php jquery ajax

我正在调用 Api $url = 'https://plapi.ecomexpress.in/track_me/api/mawbd/?awb=awbnumber&order=' . $orderrecords[$k]["order_id"] . '&username=admin&password=admin123';并获取所有订单IDS &的状态结果当我们刷新php页面时在php页面中显示。

现在我想通过复选框选择订单ID,而不是当我点击“显示状态”按钮时,而不是我想要呼叫Api&更新网页中的选定订单ID 状态

enter image description here

<p><button type= "button" class="call">Show Status</button></p>

    <table class="tbl-qa" border="1">
        <thead>
            <tr>    
               <th class="table-header"></th>     
               <th class="table-header">ORDERID</th>                                                      
               <th class="table-header">Status</th>                    
            </tr>
        </thead>

       <tbody id="table-body">
<?php
$tabindex = 1;

if (!empty($orderrecords))
    {
    foreach($orderrecords as $k => $v)
        { ?>

        <?php
        $hide = '';
        $data['username'] = 'admin';
        $data['password'] = 'admin123';     

        $url = 'https://plapi.ecomexpress.in/track_me/api/mawbd/?awb=awbnumber&order=' . $orderrecords[$k]["order_id"] . '&username=admin&password=admin123';
        $ch = curl_init();
        // some curl code
        $res = explode("\n", $output);
        if (!isset($res[13]))
            {
            $res[13] = null;
            }

        $status = $res[13];
?>

<tr class="table-row" id="table-row-<?php echo $orderrecords[$k]["id"]; ?>" tabindex="<?php echo $tabindex; ?>">

<td><input onclick="assignorderids('<?php echo $orderrecords[$k]["order_id"]; ?>')" type="checkbox" name="assigneeid" id="assigneeid-<?php echo $orderrecords[$k]["order_id"]; ?>" value="<?php echo $orderrecords[$k]["order_id"]; ?>"></td>

<td><?php echo $orderrecords[$k]["order_id"]; ?></td>             
<td><?php echo $status; ?></td>

</tr>


 <?php
 $tabindex++;
 }
    } ?>

    </tbody>
    </table>

请帮助我如何实现这一目标?

更新:assignorderids功能

function assignorderids(oid)
    {
        var checkstatus=$("#assigneeid-"+oid).is(":checked");       
        var morderId =document.getElementById("orderids").value;
        if(checkstatus==false)
        {
            var arrayorder = JSON.parse("[" + morderId + "]");
            document.getElementById("orderids").value='';
            for (var i = 0; i < arrayorder.length; i++) {           
                var orderstatusValue=arrayorder[i];
                if(orderstatusValue!=oid){
                    if (document.getElementById("orderids").value=='')
                    {
                        document.getElementById("orderids").value=orderstatusValue; 
                    }
                    else
                    {
                        var newvalue=document.getElementById("orderids").value;
                        document.getElementById("orderids").value=newvalue+","+orderstatusValue;                        
                    }
                }                       
            }
        }
        else
        {
            if(morderId=='')
            {
                document.getElementById("orderids").value=oid;
            }
            else
            {
                document.getElementById("orderids").value=morderId+","+oid;
            }
        }
    }

网址输出

enter image description here

0 个答案:

没有答案