Я хочу вставить выбранное значение переключателя в базу данных. просто «да» или «нет». если кто-нибудь может дать мне представление, это будет большой помощью. Я использую frameworkignign framework. Заранее спасибо.Как вставить значение переключателя в базу данных?
Модель
function add_reservation($reservation_model) {
return $this->db->insert('reservations', $reservation_model);
}
Контроллер
function add_reservation() {
$reservation_model = new Reservation_model();
$reservation_service = new Reservation_service();
$reservation_model->set_date_cal(trim($this->input->post('date', TRUE)));
$reservation_model->set_date(strtotime($this->input->post('date', TRUE)));
$reservation_model->set_title(trim($this->input->post('selected_hall', TRUE)));
$reservation_model->set_type(trim($this->input->post('selected_time', TRUE)));
$reservation_model->set_description(trim($this->input->post('name', TRUE)));
$reservation_model->set_advanced_payment_status(trim($this->input->post('advanned_paid_radio_button', TRUE)));
$reservation_model->set_paid_amount(trim($this->input->post('paid_amount', TRUE)));
$reservation_model->set_fax(trim($this->input->post('fax', TRUE)));
$reservation_model->set_telephone_number(trim($this->input->post('telephone', TRUE)));
$reservation_model->set_address(trim($this->input->post('address', TRUE)));
$reservation_model->set_menu_no(trim($this->input->post('selected_menu_number', TRUE)));
$reservation_model->set_menu_price_per_plate(trim($this->input->post('menu_price', TRUE)));
$reservation_model->set_is_deleted('0');
$this->db->last_query();
echo $reservation_service->add_reservation($reservation_model);
}
Посмотреть
<label for="advanced_paid">Advanced paid</label>
<div id="advanned_paid_radio_button">
<input type="radio" onclick="myFunction()" name="optionsRadios" id="yes" value="yes"> Yes
<input type="radio" onclick="myNoFunction()" name="optionsRadios" id="no" value="no"> No
</div>
В JavaScript у меня есть это ,
function myFunction() {
if ($('input[id="yes').is(':checked')) {
$('div[id="paid"]').show();
}
if ($('input[id="no"]').is(':checked')) {
$('div[id="paid"]').hide();
}
}
function myNoFunction() {
if ($('input[id="no"]').is(':checked')) {
$('div[id="paid"]').hide();
}
}
В чем проблема, с которой вы сталкиваетесь сейчас? –
@SulthanAllaudeen Когда я вставляю данные в базу данных, значение кнопки радио не идет. Я хочу отправить значение переключателя с нажатой кнопкой. как «да» или «нет» –