I know this is a JS question.. but i have a string being passed through the url and it has a comma leading it... IE: I have this function: this is running through a for loop to get all the checked boxes in all forms on the page. var elete_name_array = new Array(); if ((formele.checked == true) && (id)) { delete_name_array[i] = id; } //this is a pupup window function i have new_window(''../popup.php?names='' + delete_name_array); when i view the url this is whats getting passed... popup.php?string=,,,,,,,,,bob,mary,sue,bill,mike even though i told it if ((formele.checked == true) && (id)) Im not sure why its doing that I would like to trim this value before it gets sent to the url...(all post and pre commas) can someone please tell me how to do this.. i tried googgling it.. not sure why im not finding what im looking to do. probably the bes thing is to be sure there is a checked value which that IF statement should be doing in eitehr solution.. id still like to know how to trim these types of values that are statically specified or a string of stripped chars via an array! tks much guys... I hope i have provided enough info this time :) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Jan 31, 6:45 pm, Stripe-man <rems...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I know this is a JS question.. but i have a string being passed through the > url and it has a comma leading it... IE: > > I have this function: > > this is running through a for loop to get all the checked boxes in all forms > on the page. > > var elete_name_array = new Array();It is generally better to use an initialiser: var delete_name_array = [];> > if ((formele.checked == true) && (id)) {A simpler and sufficient test is: if (formele.checked && id) { Where is the value of ''id'' set?> > delete_name_array[i] = id;Where is the value of i set? You might want: delete_name_array.push(id);> } > > //this is a pupup window function i have > new_window(''../popup.php?names='' + delete_name_array); > > when i view the url this is whats getting passed... > popup.php?string=,,,,,,,,,bob,mary,sue,bill,mikeYou should be doing something like: var n = encodeURIComponent(delete_name_array.join('','')); new_window(''../popup.php?names='' + n, ... );> > even though i told it > if ((formele.checked == true) && (id)) > > Im not sure why its doing thatProbably because of the value of i, which I guess is being set as a counter in the loop so that you create a sparse array, hence the elisions. For straight javascript questions, use comp.lang.javascript: <URL: http://groups.google.com/group/comp.lang.javascript > -- Rob --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
WOW>> awsome!! that worked... all i have to do now is split the string!! Thanks so much! and thanks so much for the js resource and the awesomely fast reply!!! This is great!!! On 1/31/07, RobG <rgqld-AFFH1GffN5hPR4JQBCEnsQ@public.gmane.org> wrote:> > > > > On Jan 31, 6:45 pm, Stripe-man <rems...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I know this is a JS question.. but i have a string being passed through > the > > url and it has a comma leading it... IE: > > > > I have this function: > > > > this is running through a for loop to get all the checked boxes in all > forms > > on the page. > > > > var elete_name_array = new Array(); > > It is generally better to use an initialiser: > > var delete_name_array = []; > > > > > > if ((formele.checked == true) && (id)) { > > A simpler and sufficient test is: > > if (formele.checked && id) { > > Where is the value of ''id'' set? > > > > > delete_name_array[i] = id; > > Where is the value of i set? You might want: > > delete_name_array.push(id); > > > > } > > > > //this is a pupup window function i have > > new_window(''../popup.php?names='' + delete_name_array); > > > > when i view the url this is whats getting passed... > > popup.php?string=,,,,,,,,,bob,mary,sue,bill,mike > > You should be doing something like: > > var n = encodeURIComponent(delete_name_array.join('','')); > new_window(''../popup.php?names='' + n, ... ); > > > > > > even though i told it > > if ((formele.checked == true) && (id)) > > > > Im not sure why its doing that > > Probably because of the value of i, which I guess is being set as a > counter in the loop so that you create a sparse array, hence the > elisions. > > For straight javascript questions, use comp.lang.javascript: > > <URL: http://groups.google.com/group/comp.lang.javascript > > > > -- > Rob > > > > >-- "I have learned that you should''nt compare yourself to others - they are more screwed up than you think." ...unknown "In the 60''s, people took acid to make the world weird. Now the world is weird and people take Prozac to make it normal." ..unknown _____________________________ Terry Remsik stripe-man.dyndns.org remsikt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Christian Schaefer
2007-Jan-31 09:51 UTC
Re: Trimming Comma from the beginning of string...
hey stripe-man, this should be a more ''prototype way'' to achieve what you''re after. encodeURIComponent($$(''.css_class_of_your_checkboxes'').findAll(function(cb){return cb.checked}).pluck(''id'').join('','')) cheers /christian --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
oh... ok!! I will try that as well... BTW... Rob (or anyone) if i change my field name to: delete_names_array to delete_names_array[] how can i properly change this THIS WORKS=> formele = eval(document."+ form + id ".delete_names_array" + id + ''[]''); to this does not: formele = eval(document."+ form + id ".delete_names_array" + id + ''[]''); Tanks in advanced. :) On 1/31/07, Christian Schaefer <caefer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > hey stripe-man, > > this should be a more ''prototype way'' to achieve what you''re after. > > > encodeURIComponent($$(''.css_class_of_your_checkboxes'').findAll(function(cb){return > cb.checked}).pluck(''id'').join('','')) > > > cheers > /christian >-- "I have learned that you should''nt compare yourself to others - they are more screwed up than you think." ...unknown "In the 60''s, people took acid to make the world weird. Now the world is weird and people take Prozac to make it normal." ..unknown _____________________________ Terry Remsik stripe-man.dyndns.org remsikt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
btw.... it tells me that $$ is not defined... what am i missing ? On 1/31/07, Christian Schaefer <caefer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > hey stripe-man, > > this should be a more ''prototype way'' to achieve what you''re after. > > > encodeURIComponent($$(''.css_class_of_your_checkboxes'').findAll(function(cb){return > cb.checked}).pluck(''id'').join('','')) > > > cheers > /christian >-- "I have learned that you should''nt compare yourself to others - they are more screwed up than you think." ...unknown "In the 60''s, people took acid to make the world weird. Now the world is weird and people take Prozac to make it normal." ..unknown _____________________________ Terry Remsik stripe-man.dyndns.org remsikt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Christian Schaefer
2007-Jan-31 11:18 UTC
Re: Trimming Comma from the beginning of string...
Stripe-man wrote:> btw.... > it tells me that $$ is not defined... > > what am i missing ?a more up-to-date version of prototype? you''re using 1.4? see http://www.prototypejs.org /christian --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Jan 31, 9:05 pm, Stripe-man <rems...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> oh... ok!! I will try that as well... > > BTW... Rob (or anyone) > > if i change my field name to: delete_names_array to delete_names_array[] > how can i properly change this > > THIS WORKS=> formele = eval(document."+ form + id ".delete_names_array" + > id + ''[]'');As I said, you will get better javascript support at clj - the answer to your question is on that news group''s FAQ: <URL: http://www.jibbering.com/faq/#FAQ4_25 > You should assume that any use of eval is totally unwarranted - the cases where its use is appropriate are few and far between. If you are trying to serialise a form''s content, then use one of the many form serialisation functions that have already been written. Prototype.js has one, but there are others. AjaxToolbox has a good one: <URL: http://www.ajaxtoolbox.com/request/ documentation.php#serializeForm > Finally, your form controls should be using names, not ids and you should be basing your logic on their value, not using the ID as a pseudo-value. That way you just serialise the form and send it, most servers will be (more or less) oblivious to how the request was sent and will handle standards-compliant requests automatically. That way, if scripting is not supported or disabled, your form submits and gets the job done the old way. If scripting is available, you use AJAX and provide a bit of convenience for the user. -- Rob --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
THanks for that tip.. that worked. I am still trying to learn all i can about ajax and prototype its a lot to soak up. This page im working on is tricky. It can have hundreds of records on it with each record having about 4 forms that can be used with it. the [] was necessary so that a ''select all'' feature would work (i have been using it with ONE form and mulitple rows and never had any problems.. But I had to get a bit creative for it to work with mulitple forms but the same field name. I''m sure there is a better way to do it.. I will have to revisit it later. I did try to find something relating to the [] and grabbing those fields.. But didnt find much. I think I have to how to search better. Thanks for your time and trouble Rob..... Terry On 1/31/07, RobG <rgqld-AFFH1GffN5hPR4JQBCEnsQ@public.gmane.org> wrote:> > > > > On Jan 31, 9:05 pm, Stripe-man <rems...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > oh... ok!! I will try that as well... > > > > BTW... Rob (or anyone) > > > > if i change my field name to: delete_names_array to > delete_names_array[] > > how can i properly change this > > > > THIS WORKS=> formele = eval(document."+ form + id > ".delete_names_array" + > > id + ''[]''); > > As I said, you will get better javascript support at clj - the answer > to your question is on that news group''s FAQ: > > <URL: http://www.jibbering.com/faq/#FAQ4_25 > > > You should assume that any use of eval is totally unwarranted - the > cases where its use is appropriate are few and far between. > > If you are trying to serialise a form''s content, then use one of the > many form serialisation functions that have already been written. > Prototype.js has one, but there are others. AjaxToolbox has a good > one: > > <URL: http://www.ajaxtoolbox.com/request/ > documentation.php#serializeForm > > > > Finally, your form controls should be using names, not ids and you > should be basing your logic on their value, not using the ID as a > pseudo-value. That way you just serialise the form and send it, most > servers will be (more or less) oblivious to how the request was sent > and will handle standards-compliant requests automatically. > > That way, if scripting is not supported or disabled, your form submits > and gets the job done the old way. If scripting is available, you use > AJAX and provide a bit of convenience for the user. > > > -- > Rob > > > > >-- "I have learned that you should''nt compare yourself to others - they are more screwed up than you think." ...unknown "In the 60''s, people took acid to make the world weird. Now the world is weird and people take Prozac to make it normal." ..unknown _____________________________ Terry Remsik stripe-man.dyndns.org remsikt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
oh.. and I have subscribed to that group you pointed me to.. tks! On 1/31/07, Stripe-man <remsikt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > THanks for that tip.. that worked. > > I am still trying to learn all i can about ajax and prototype its a lot > to soak up. > This page im working on is tricky. > > It can have hundreds of records on it with each record having about 4 > forms that can be used with it. > the [] was necessary so that a ''select all'' feature would work (i have > been using it with ONE form and mulitple rows > and never had any problems.. > > But I had to get a bit creative for it to work with mulitple forms but the > same field name. > I''m sure there is a better way to do it.. I will have to revisit it later. > > I did try to find something relating to the [] and grabbing those fields.. > But didnt find much. I think I have to how to search better. > > Thanks for your time and trouble Rob..... > > Terry > > On 1/31/07, RobG <rgqld-AFFH1GffN5hPR4JQBCEnsQ@public.gmane.org> wrote: > > > > > > > > > > On Jan 31, 9:05 pm, Stripe-man <rems...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > wrote: > > > oh... ok!! I will try that as well... > > > > > > BTW... Rob (or anyone) > > > > > > if i change my field name to: delete_names_array to > > delete_names_array[] > > > how can i properly change this > > > > > > THIS WORKS=> formele = eval(document."+ form + id > > ".delete_names_array" + > > > id + ''[]''); > > > > As I said, you will get better javascript support at clj - the answer > > to your question is on that news group''s FAQ: > > > > <URL: http://www.jibbering.com/faq/#FAQ4_25 > > > > > You should assume that any use of eval is totally unwarranted - the > > cases where its use is appropriate are few and far between. > > > > If you are trying to serialise a form''s content, then use one of the > > many form serialisation functions that have already been written. > > Prototype.js has one, but there are others. AjaxToolbox has a good > > one: > > > > <URL: http://www.ajaxtoolbox.com/request/ > > documentation.php#serializeForm > > > > > > > Finally, your form controls should be using names, not ids and you > > should be basing your logic on their value, not using the ID as a > > pseudo-value. That way you just serialise the form and send it, most > > servers will be (more or less) oblivious to how the request was sent > > and will handle standards-compliant requests automatically. > > > > That way, if scripting is not supported or disabled, your form submits > > and gets the job done the old way. If scripting is available, you use > > AJAX and provide a bit of convenience for the user. > > > > > > -- > > Rob > > > > > > > > > > > > > -- > "I have learned that you should''nt compare yourself to others - they are > more screwed up than you think." ...unknown > > "In the 60''s, people took acid to make the world weird. Now the world is > weird and people take Prozac to make it normal." ..unknown > _____________________________ > Terry Remsik > stripe-man.dyndns.org > remsikt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org >-- "I have learned that you should''nt compare yourself to others - they are more screwed up than you think." ...unknown "In the 60''s, people took acid to make the world weird. Now the world is weird and people take Prozac to make it normal." ..unknown _____________________________ Terry Remsik stripe-man.dyndns.org remsikt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Regarding your example, the var definition "elete_name_array" doesn''t match "delete_name_array" used in the loop, but perhaps you''re declaring it elsewhere. Checkboxes are only passed when ticked. However, you might want to add another condition to confirm the input type is indeed a checkbox. Stripe-man <remsikt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: I know this is a JS question.. but i have a string being passed through the url and it has a comma leading it... IE: I have this function: this is running through a for loop to get all the checked boxes in all forms on the page. var elete_name_array = new Array(); if ((formele.checked == true) && (id)) { delete_name_array[i] = id; } //this is a pupup window function i have new_window(''../popup.php?names='' + delete_name_array); when i view the url this is whats getting passed... popup.php?string=,,,,,,,,,bob,mary,sue,bill,mike even though i told it if ((formele.checked == true) && (id)) Im not sure why its doing that I would like to trim this value before it gets sent to the url...(all post and pre commas) can someone please tell me how to do this.. i tried googgling it.. not sure why im not finding what im looking to do. probably the bes thing is to be sure there is a checked value which that IF statement should be doing in eitehr solution.. id still like to know how to trim these types of values that are statically specified or a string of stripped chars via an array! tks much guys... I hope i have provided enough info this time :) --~--~---------~--~----~------------~-------~--~----~ 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 John... Yea.. it was a typo when i was copying and pasting the code. Ill try to get all of the code in here tomorrow.. ;) JS is difficult to learn least for me.. and also trying to get some of the prototype stuff down as well. I do appreciate all of your all'' help and patience ;) On 1/31/07, John <realistindenial-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> > Regarding your example, the var definition "elete_name_array" doesn''t > match "delete_name_array" used in the loop, but perhaps you''re declaring it > elsewhere. > > Checkboxes are only passed when ticked. However, you might want to add > another condition to confirm the input type is indeed a checkbox. > > *Stripe-man <remsikt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>* wrote: > > > I know this is a JS question.. but i have a string being passed through > the url and it has a comma leading it... IE: > > I have this function: > > this is running through a for loop to get all the checked boxes in all > forms on the page. > > var elete_name_array = new Array(); > > if ((formele.checked == true) && (id)) { > > delete_name_array[i] = id; > > } > > //this is a pupup window function i have > new_window(''../popup.php?names='' + delete_name_array); > > when i view the url this is whats getting passed... > popup.php?string=,,,,,,,,,bob,mary,sue,bill,mike > > even though i told it > if ((formele.checked == true) && (id)) > > Im not sure why its doing that > > I would like to trim this value before it gets sent to the url...(all post > and pre commas) > > can someone please tell me how to do this.. i tried googgling it.. not > sure why im not finding what im looking to do. > > probably the bes thing is to be sure there is a checked value which that > IF statement should be doing in eitehr solution.. > id still like to know how to trim these types of values that are > statically specified or a string of stripped chars via an array! > > tks much guys... I hope i have provided enough info this time :) > > > > > > > >-- "I have learned that you should''nt compare yourself to others - they are more screwed up than you think." ...unknown "In the 60''s, people took acid to make the world weird. Now the world is weird and people take Prozac to make it normal." ..unknown _____________________________ Terry Remsik stripe-man.dyndns.org remsikt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---