php - Preset currency value on select codeigniter -
i have select box currency 1 , 2, currency 1 euro. want select box preset value 1 euro.
i using controller currency information this.
$data = array( 'sexlist' => $this->localization->gettextparamvalues(null, 'user', 'sex'), 'countrylist' => $this->localization->getcountrylist(), 'currencylist' => $this->localization->getcurrencylist(), 'languagelist' => $this->localization->getlanguagelist(), 'user' => $userexist, 'userinfo' => $this->user_profile->getuserinfo(), 'currency' => $this->localization->getcompanycurrency() ); $this->load->view('header', $this->history->getpreviouspageinarray()); $this->load->view('borrow_registerpage_view',$data); the currency pushing value 1 data array, in html file doesnt preset automatically. dont know wrong.
here html code, need preset value 1 in table selects 1 euro.
<?php echo '<select name="currency_select" id="my_profile_select_currency" class="form-control country_style">'; if(!($user['currency'] > 0)){ echo '<option value="0">'.lang("myprofile_pinfo_no_currency_set").'</option>'; foreach ($currencylist $currency){ echo '<option value="' . $currency->id. '">' . $currency->name . '</option>'; } }else{ foreach ($currencylist $currency){ echo '<option value="' . $currency->id. '"'; if($currency->id==$user['currency']){ echo 'selected'; } echo '>' . $currency->name .''; echo '</option>'; } } echo '</select>' ?>
you need change view
$opt = array(); foreach ($currencylist $currency){ $opt[$currency->id] = $currency->name; } echo form_dropdown('currency_select', $opt, set_value('currency_select', $user['currency'], 'id="my_profile_select_currency" class="form-control country_style"');
Comments
Post a Comment