Hi, 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 Thx for your answers -- Posted via http://www.ruby-forum.com/.
Not even one response? -- Posted via http://www.ruby-forum.com/.
It is not quite clear what you are trying to do. But it seems like you are reinventing a square wheel :) Did you try some ready solutions like http://github.com/mbleigh/acts-as-taggable-on/ ? Regards -- Vitaly Kushner http://twitter.com/vkushner Founder, Astrails Ltd. http://astrails.com Check out our blog: http://blog.astrails.com On Jul 7, 1:20 pm, Hans Hartmann <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi, > > 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 > > Thx for your answers > -- > Posted viahttp://www.ruby-forum.com/.
Hans Hartmann wrote: [...]> 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 = falseWhy on earth would you do this in client-side JavaScript instead of on the server side? That doesn''t appear to make sense.> > > Thx for your answersBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
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... -- Posted via http://www.ruby-forum.com/.
Hans Hartmann wrote:> I tried and tried and triedAnd what did you try?> ... 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.> > Thx till now...Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.