I want to add a tag-search to my page. The tags can be given to each
item by clicking a checkbox. The value of the checkboxes is saved in the
table using the check_box_tag.
By editing the tags of an item (refreshing the page) the checkboxes
delete their status - reset theirselves.
Question:
How can I check if a box was clicked last time(value saved in the table)
into the blue:
if “value” exists in “table”
document.getElementById(“checkbox1”).checked = true
if “value” doesn’t exist in “table”
document.getElementById(“checkbox1”).checked = false
Question:
How can I check if a box was clicked last time(value saved in the table)
Look at the appropriate field in the database. If you use form_for, it
does that for free.
into the blue:
if “value” exists in “table”
document.getElementById(“checkbox1”).checked = true
if “value” doesn’t exist in “table”
document.getElementById(“checkbox1”).checked = false
Why on earth would you do this in client-side JavaScript instead of on
the server side? That doesn’t appear to make sense.
… but everything in my checkbox is deleted
after refreshing the page (instead of the values in my database) so how
can I ask for them.
The behavior of unsubmitted forms in the browser on page refresh is
somewhat browser-dependent, but most browsers will reset them. This is
what users expect.
Why do you need this functionality, anyway? If you explain what you’re
trying to achieve by doing this, perhaps we can be of more help.
I tried and tried and tried … but everything in my checkbox is deleted
after refreshing the page (instead of the values in my database) so how
can I ask for them.
Thx till now…
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.