hi, i m working on a project, and it has some special features, one of them is that when a submit button is clicked, it should send some value back to the server. but the number of parameter is arbitrary, i m wondering if i can pass the parameters in using a long string. e.g. ------------------------------------------------------------------------------------------------------------------------------------------------------- function submitForm(targetId) { var paras = ''par1=parameter1_value\&par2=parameter2_value''; var target = document.getElementById(targetId); var url = ''some url/''; new Ajax.Update(target, url, {method:''post'', parameters:paras}); } ------------------------------------------------------------------------------------------------------------------------------------------------------- this is what i m trying to do. unfortunately, it doesn''t work. is it possible to have this in an Ajax call? Thanks for ur help! Best regards --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
if its in a form do Form.serialize(''form_id'') On 9/1/07, NeedForSpeed <liudi_wang-/E1597aS9LT0CCvOHzKKcA@public.gmane.org> wrote:> > > hi, > i m working on a project, and it has some special features, one of > them is that when a submit button is clicked, it should send some > value back to the server. but the number of parameter is arbitrary, i > m wondering if i can pass the parameters in using a long string. e.g. > > > ------------------------------------------------------------------------------------------------------------------------------------------------------- > function submitForm(targetId) { > var paras = ''par1=parameter1_value\&par2=parameter2_value''; > var target = document.getElementById(targetId); > var url = ''some url/''; > new Ajax.Update(target, url, {method:''post'', parameters:paras}); > } > > ------------------------------------------------------------------------------------------------------------------------------------------------------- > this is what i m trying to do. unfortunately, it doesn''t work. is it > possible to have this in an Ajax call? > > Thanks for ur help! > > Best regards > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, I am new to prototype/scriptaculous/javascript this week, but do a lot of PHP scripting and seem to be muddling through well. I have already created a few global type scripts that I use to create live searches, text field suggestions, select list updates etc. and to make them work for any table/field combination I pass a fair few variables through to vairous scripts and Ajax calls. The way I have approached this is to pass an array into my javascript function as follows ... yourFuncion(this, {param1: ''value1'', param2: ''value2'', param3: ''value3''}) The js function should then look something like this yourFunction(element, params) { } You can then reference any of the values within the array easily e.g. alert(params.param1); Also you can easily pass the array to any other function e.g. yourFunction2(params) If you want to say make an Ajax.Updater request passing the paramaters whilst adding/updating values then you can do so as follows: new Ajax.Updater(containter, script, { method:''get'', parameters: Object.extend ({newParam: ''newValue'', param1: ''updatedValue''}, params) }); Hope this makes sense, helped me a lot when I got my head around it. Paul. On Sep 1, 8:36 pm, NeedForSpeed <liudi_w...-/E1597aS9LT0CCvOHzKKcA@public.gmane.org> wrote:> hi, > i m working on a project, and it has some special features, one of > them is that when a submit button is clicked, it should send some > value back to the server. but the number of parameter is arbitrary, i > m wondering if i can pass the parameters in using a long string. e.g. > > ------------------------------------------------------------------------------------------------------------------------------------------------------- > function submitForm(targetId) { > var paras = ''par1=parameter1_value\&par2=parameter2_value''; > var target = document.getElementById(targetId); > var url = ''some url/''; > new Ajax.Update(target, url, {method:''post'', parameters:paras});} > > ------------------------------------------------------------------------------------------------------------------------------------------------------- > this is what i m trying to do. unfortunately, it doesn''t work. is it > possible to have this in an Ajax call? > > Thanks for ur help! > > Best regards--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
hi paul, thanks for sharing your script. your idea does help me alot, my problem is solved by passing in an array into the parameter field of Ajax. Thanks for ur help! cheers On Sep 2, 8:19 pm, WebbedIT <p...-BKqkkOijtfm9FHfhHBbuYA@public.gmane.org> wrote:> Hi, > > I am new to prototype/scriptaculous/javascript this week, but do a lot > of PHP scripting and seem to be muddling through well. > > I have already created a few global type scripts that I use to create > live searches, text field suggestions, select list updates etc. and to > make them work for any table/field combination I pass a fair few > variables through to vairous scripts and Ajax calls. The way I have > approached this is to pass an array into my javascript function as > follows ... > > yourFuncion(this, {param1: ''value1'', param2: ''value2'', param3: > ''value3''}) > > The js function should then look something like this > > yourFunction(element, params) { > > } > > You can then reference any of the values within the array easily > > e.g. alert(params.param1); > > Also you can easily pass the array to any other function > > e.g. yourFunction2(params) > > If you want to say make an Ajax.Updater request passing the paramaters > whilst adding/updating values then you can do so as follows: > > new Ajax.Updater(containter, script, { method:''get'', > parameters: Object.extend ({newParam: ''newValue'', param1: > ''updatedValue''}, params) > }); > > Hope this makes sense, helped me a lot when I got my head around it. > > Paul. > > On Sep 1, 8:36 pm, NeedForSpeed <liudi_w...-/E1597aS9LT0CCvOHzKKcA@public.gmane.org> wrote: > > > hi, > > i m working on a project, and it has some special features, one of > > them is that when a submit button is clicked, it should send some > > value back to the server. but the number of parameter is arbitrary, i > > m wondering if i can pass the parameters in using a long string. e.g. > > > ------------------------------------------------------------------------------------------------------------------------------------------------------- > > function submitForm(targetId) { > > var paras = ''par1=parameter1_value\&par2=parameter2_value''; > > var target = document.getElementById(targetId); > > var url = ''some url/''; > > new Ajax.Update(target, url, {method:''post'', parameters:paras});} > > > ------------------------------------------------------------------------------------------------------------------------------------------------------- > > this is what i m trying to do. unfortunately, it doesn''t work. is it > > possible to have this in an Ajax call? > > > Thanks for ur help! > > > Best regards--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---