Mike Dershowitz wrote:> Hi:
>
> Is there a way to set a session variable in a check box that''s not
in a
> form nor linked to a controller? The checkbox value would also be the
> value of the session variable I want it to set. I assume I have to put
> this in a form. Any suggestions?
>
> Thanks very much in advance!
>
> Mike
just an idea, but you could do an ajax call on an onchange event of the
checking-of-the-box:
<input type="checkbox" value="parameter_for_session"
name="session_setter" onchange="ajax_call(''<%=
url_for
:controller=>:example, :action=>:set %>'')">
create the function
<script type="text/javascript">
function ajax_call(url) { new Ajax.Request(url, {asynchronous:true,
evalScripts:true, parameters:Form.serialize(this)}); return false; }
</script>
and then just do an action in the ExampleController
def set
session[:checkbox] = params[:session_setter]
render :nothing => true
end
all untested code...might need to modify the ajax statement above to
pass the param[:session_setter] in "parameters:..." but an idea, no?
hth
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---