简体   繁体   English

用从php生成的选项刷新html select

[英]Refresh html select with options generated from php

Im trying to refresh this 我正在尝试刷新

<div id="refresh_sconto">
    <select id="articolo_sconto" class="col-sm-11" />
        <option value="0"></option>
    <?
        $ids_sconti= $rpc->search("x_sconti","x_company_id.id","=",$_SESSION['company_id']);
        $sconti= $rpc->read($ids_sconti,array(),"x_sconti");

        foreach ($sconti as $key => $sconto) {
            if($sconto['x_tipo']==1)
                echo "<option rel='".$sconto['x_tipo']."H".$sconto['x_valore']."' value='".$sconto['id']."'>".$sconto['x_valore']." - ".$sconto['x_descrizione']."</option>";
            else
                echo "<option rel='".$sconto['x_tipo']."H".$sconto['x_valore']."' value='".$sconto['id']."'>".$sconto['x_valore']." % - ".$sconto['x_descrizione']."</option>";
        }

    ?>
    <option value="new" class="text-danger">--NUOVO-SCONTO--</option>
    </select>
</div>

with this code: 使用此代码:

$('#refresh_sconto').load("crea-fattura.php #refresh_sconto");

but the select dont work anymore. 但是选择不再起作用。 I ve a form that make insert a new "sconto" then on the ajax success response i ve to refresh that div. 我有一个表格,可以插入一个新的“ sconto”,然后在ajax成功响应上刷新该div。

I really cant figure out the solution :/ 我真的不知道解决方案:/

you can try this 你可以试试这个

$("#articolo_sconto select").val("0");

this will select your first option. 这将选择您的第一个选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM