Hey David,
I am a little confused on what you're trying to do, but if
you're trying to collect the values of the form fields, try using the
$F function, it simplifies the operation you're attempting. Try
testing this snippet and see what you can come up with.
var arr = [];
for(var i = count; i > 0; i--) {
arr.push($F("username["+count+"]"));
arr should now be an array string values from the form elements you're
looking for, Remember using name and id on an element can be tricky,
if you're using both make sure they're the same value.
On May 5, 9:43 am, ahseed <[EMAIL PROTECTED]> wrote:
> Hi there,
>
> I'm trying to fectch value of input for comparison. But return an
> empty value even if the value is non empty...
>
> Here is the (problematic) part of my code (prototype 1.6.0.2) :
>
> [JAVASCRIPT CODE]
> var countUser = 3;
> for(var i = countUsers; i > 0; i--) {
> var testUser = $('username['+ countUsers +']').value;
> // OR var testUser = $F('username['+ countUsers +']');
> // OR var testUser = document.getElementById('username['+ countUsers
> +']').value;
> alert(countUsers +" :: "+ testUser +" == "+ myUser);
>
> }
>
> It says for exemple : 1 :: == John Paul Jones !!!
> The input value is never shown !
>
> Any ideas ?
>
> Thank you for your help
>
> David
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---