미채택 완료

옵션 셀렉트 박스를 라디오 버튼으로 할수 있을까요?

2015-03-24 (화) 11:34:24 4,043

라디오 버튼으로 만들어서 type=이미지 로 하려고 합니다.

어떻게 해야 할까요? 

Copy
​​​​// 상품 선택옵션function get_item_options($it_id, $subject){    global $g5;    if(!$it_id || !$subject)        return '';    $sql = " select * from {$g5['g5_shop_item_option_table']} where io_type = '0' and it_id = '$it_id' and io_use = '1' order by io_no asc ";    $result = sql_query($sql);    if(!mysql_num_rows($result))        return '';    $str = '';    $subj = explode(',', $subject);    $subj_count = count($subj);    if($subj_count > 1) {        $options = array();        // 옵션항목 배열에 저장        for($i=0; $row=sql_fetch_array($result); $i++) {            $opt_id = explode(chr(30), $row['io_id']);            for($k=0; $k<$subj_count; $k++) {                if(!is_array($options[$k]))                    $options[$k] = array();                if($opt_id[$k] && !in_array($opt_id[$k], $options[$k]))                    $options[$k][] = $opt_id[$k];            }        }        // 옵션선택목록 만들기        for($i=0; $i<$subj_count; $i++) {            $opt = $options[$i];            $opt_count = count($opt);            $disabled = '';            if($opt_count) {                $seq = $i + 1;                if($i > 0)                    $disabled = ' disabled="disabled"';                $str .= '<tr>'.PHP_EOL;                $str .= '<th><label for="it_option_'.$seq.'">'.$subj[$i].'</label></th>'.PHP_EOL;                $select = '<select id="it_option_'.$seq.'" class="it_option"'.$disabled.'>'.PHP_EOL;                $select .= '<option value="">선택</option>'.PHP_EOL;                for($k=0; $k<$opt_count; $k++) {                    $opt_val = $opt[$k];                    if(strlen($opt_val)) {                        $select .= '<option value="'.$opt_val.'">'.$opt_val.'</option>'.PHP_EOL;                    }                }                $select .= '</select>'.PHP_EOL;                $str .= '<td>'.$select.'</td>'.PHP_EOL;                $str .= '</tr>'.PHP_EOL;            }        }    } else {        $str .= '<tr>'.PHP_EOL;        $str .= '<th><label for="it_option_1">'.$subj[0].'</label></th>'.PHP_EOL;        $select = '<select id="it_option_1" class="it_option">'.PHP_EOL;        $select .= '<option value="">선택</option>'.PHP_EOL;        for($i=0; $row=sql_fetch_array($result); $i++) {            if($row['io_price'] >= 0)                $price = '&nbsp;&nbsp;+ '.number_format($row['io_price']).'원';            else                $price = '&nbsp;&nbsp; '.number_format($row['io_price']).'원';            if(!$row['io_stock_qty'])                $soldout = '&nbsp;&nbsp;[품절]';            else                $soldout = '';            $select .= '<option value="'.$row['io_id'].','.$row['io_price'].','.$row['io_stock_qty'].'">'.$row['io_id'].$price.$soldout.'</option>'.PHP_EOL;        }        $select .= '</select>'.PHP_EOL;        $str .= '<td>'.$select.'</td>'.PHP_EOL;        $str .= '</tr>'.PHP_EOL;    }    return $str;}​
|

답변 1개

해당 함수를 복사하셔서 함수명을 변경하시고.. select 박스를 출력하는 코드부분을 radio 버튼으로 출력되도록 처리하시면 됩니다.

답변을 작성하려면 로그인이 필요합니다.