On Jan 31, 6:45 pm, Stripe-man <[EMAIL PROTECTED]> 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
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---