PHP combobox can't save the selected value on Edit Page

Posted by bEtTy Barnes on Stack Overflow See other posts from Stack Overflow or by bEtTy Barnes
Published on 2012-11-12T04:26:25Z Indexed on 2012/11/12 5:00 UTC
Read the original article Hit count: 205

Filed under:
|
|

hello I've got problem with my combobox. It's not saving the selected value in Edit page.

Here what I'm working with:

    private function inputCAR(){
    $html = "";
    $selectedId = $this->CAR;
    //$html .= '<option value="Roadmap Accelerator - Core">Roadmap Accelerator - Core</option>';
    //$html .= '<option value="Roadmap Accelerator - Optional Core">Roadmap Accelerator - Optional Core</option>';
    //$html .= '<option value="Regulatory">Regulatory</option>';
    //$html .= '<option value="Mission Critical">Mission Critical</option>';
    //$html .= '<option value="Various CARs/Types">Various CARs/types</option>';
    $selection = array(
            "Roadmap Accelerator - Core",
            "Roadmap Accelerator - Optional Core",
            "Regulatory",
            "Mission Critical",
            "Various CARs/types" );
    $html .= '<label for="car">CAR Type</label>';
    $html .= HTML::selectStart("car");
    foreach($selection as $value){
        $text = $value;
        $html .= HTML::option($value, $text, $selectedId == $value ? true : false);
    }
    $html .= HTML::selectEnd();
    return $html;
}

My option function:

    public static function option($value, $text, $isSelected=false) {
    $html = '<option value="' . $value . '"';
    if($isSelected) {
        $html .= ' selected="selected"';    
    }
    $html .= '>';
    $html .= $text;
    $html .= '</option>';
    return $html;
}

When I first created a record. The selected value from my combobox got saved into the DB then the page refreshed to display. When I went to edit page, to select another value, and clicked save button. On the display page, it's not saving.

For example. on Create page I selected Regulatory. then I changed my mind and changed it to Mission Critical on Edit page. On display page it is not changed.

I don't know what's wrong or what I'm missing here. Any help is welcome and truly appreciated. Thanks.

© Stack Overflow or respective owner

Related posts about php

Related posts about html