hey, i have this problem how come i always get -1 for the select list?? rhtml First, select a client. <select id="client_id" name="client[id]" onChange="submit();" > <%= options_for_select(@client_options, @client_id.to_i) %> </select><%= @client_id %> controller if @request.post? if @request.xml_http_request? #called by ajax, @client_id = -2 else @client_id = -11#params[:client][:id].nil? ? -11 : params[:client][:id] end else @client_id = -1 end shouldnt it be-11 ??? Output First, select a client. <select id="client_id" name="client[id]" onChange="submit();" > <option value="-3">Select a client</option> <option value="3">Twodecode</option> </select>-1
Hi Nick I''d use the script\breakpointer to check what''s happening here (put a breakpoint instruction just above the line you want to check, and launch the breakpointer: you''ll be able to quickly inspect the variables and know exactly what happens). Thibaut On 29/12/05, Brutyn Nick <brutyn_nick-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> > hey, > > i have this problem > > how come i always get -1 for the select list?? > > rhtml > > First, select a client. > <select id="client_id" name="client[id]" onChange="submit();" > > <%= options_for_select(@client_options, @client_id.to_i) %> > </select><%= @client_id %> > > > controller > if @request.post? > if @request.xml_http_request? #called by ajax, > @client_id = -2 > else > @client_id = -11#params[:client][:id].nil? ? -11 : > params[:client][:id] > end > else > @client_id = -1 > end > > shouldnt it be-11 ??? > > > Output > First, select a client. > <select id="client_id" name="client[id]" onChange="submit();" > > <option value="-3">Select a client</option> > <option value="3">Twodecode</option> > </select>-1 > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
hmmm, doesnt seem to work i cant find the problem, i made a lot a forms with ruby now, and this one cant i get to work :s:s cant seem to get the value of [:client][:id] , it is always -1
when i do inspect <%= params.inspect %> {"action"=>"access_geotags", "id"=>"32", "controller"=>"users"} and in the rhtml <tr> <td colspan="3"><%= check_box "user", "view_all_geotags" %> User may view all geotags from the selected clients.</td> </tr> <tr> <td colspan="3">Or, select the geotags the user can view.</td> </tr> <tr> <td colspan="3"> First, select a client. <%= @client_id.inspect %> <select id="client_id" name="client[id]" onChange="submit();"> <%= options_for_select(@client_options, @client_id.to_i) %> </select> </td> </tr> output of rhtml <tr> <td colspan="3"><input id="user_view_all_geotags" name="user[view_all_geotags]" value="1" type="checkbox"><input name="user[view_all_geotags]" value="0" type="hidden"> User may view all geotags from the selected clients.</td> </tr> <tr> <td colspan="3">Or, select the geotags the user can view.</td> </tr> <tr> <td colspan="3"> First, select a client. 3 <select id="client_id" name="client[id]" onchange="submit();"> <option value="-1">Select a client</option> <option value="235">Belcompany</option> <option value="160">BYS</option> <option value="3" selected="selected">Twodecode</option> </select> </td> </tr> in the controller if @request.post? @client_id = params[:client][:id].blank? ? -1 : params[:client][:id] else @client_id = 3 end if @request.post? @user_id = params[:id] @geotagidlist = params[:selected_geotagtype].blank? ? -1 : params[:selected_geotagtype] @user.update_attribute(:view_all_geotags, params[:user][:view_all_geotags] ) end the update works but i cant get the clientid :s:s:s