Storing checkbox data from a modal window in another Codeigniter view

Asked

Viewed 59 times

0

I need to get the selected checkbox items displayed in a modal window and move to another view however I need them to be stored in the view and I can go back and add more data without losing the already entered ones.

Someone who can help me?

1 answer

0

In general, the view that mounts the main body of the page for the user to see is also the same that at the end has a hidden modal window, which appears when the user clicks somewhere. However, even if this window comes from another view file, for the web browser they are posted by the same controller, sequentially, then they would be on the same page. Soon, via javascript or Jquery you can restore form values in the main body for modal or modal for forms in the main body.

Example: displaying an Alert with the value, via a button in the main body, of a checkbox that could be in the modal (call the modal, click and see what appears again):

<a href="#" onclick="if($("#minha_checkbox").is(':checked')){alert('Marcado!');}else{alert("Vazio');}>Clique</a>

But if there are posts of values, ie reload the page, it is impossible to store values in the view. You need to receive the data by post in control, example $this->input->post('minha_checkbox');, and play the data you receive in session (from Codeigniter), database, flashdata or cookie. And then, when you need them, check what they were, and send it to the view, either to the modal or main body, to continue working with them.

  • 1

    Thanks for returning C.Bohok, I managed to resolve this by using localstorage both to store this data either to rescue in modal or view wherever it is.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.