Hi Matt,
I'm trying to compare values to avoid a person to be present twice in
the list !
I've already tried the $F function with no success...
Trying your code (putting in an array) give me (with 3 iteration)
var arr = [];
// countUser == 3 and input fields are filled with firstname and
lastname
for(var i = countUsers; i > 0; i--) {
arr.push($F("username["+countUsers+"]"));
}
alert(arr);
> ,, <
I just tried to do this :
alert($F("username[1]")); and then it works !!!
So the problem could come from the type of iterator, should it be a
string...
Trying to force a string before passing the argument as below
var arr = [];
// countUser == 3 and input fields are filled with firstname and
lastname
for(var i = countUsers; i > 0; i--) {
var myCounter = new String(countUsers);
arr.push($F("username["+myCounter+"]"));
}
alert(arr); > SAME RESULT !
Javascript is a warm gun !
Any ideas ?
Thank you for your help !
On 5 mai, 17:28, Matt Foster <[EMAIL PROTECTED]> wrote:
> 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
-~----------~----~----~----~------~----~------~--~---