我想将购物车页面的组合框更改为文本框

时间:2019-07-01 07:12:02

标签: php

当前页面

screenshot

代码

$body .= 'select name="number" id="';
        $body .= $row["ID"] . '" onchange="changeNumber( this );"  >';
        //
        $qty = (int) $row["quantity"];
        for ($number = 0; $number <= 10; $number++) {
            $body .= '<option ';
            if ($number == $qty) {
                $body .= ' selected value="' . $number . '">' . $number . '</option>';
            } else {
                $body .= ' value="' . $number . '">' . $number . '</option>';
            }
        }
        $body .= /select>';

1 个答案:

答案 0 :(得分:-1)

尝试

$body .= '<select name="number" id="'.$row["ID"] .'" onchange="changeNumber( this );" >';
        $qty = (int) $row["quantity"];
        for ($number = 0; $number <= 10; $number++) {
            $selected = '';
            if($number == $qty) {
                $selected = "selected";
            }
            $body .= '<option '.$selected.' value="' . $number . '">' . $number . '</option>';
        }
        $body .= '</select>';