[thelist] Javascript var + string

Fabio Gomes flgomes at fazenda.sp.gov.br
Mon Jul 7 13:03:28 CDT 2003


Hi list,

   In searching of a smaller code in my javascript I'm looking for some 
code to replace the following lines (for instance):

   if(document.form.textfield_1.value == ""){
     return false;
   }
   if(document.form.textfield_2.value == ""){
     return false;
   }
   if(document.form.textfield_3.value == ""){
     return false;
   }

   With those:

   for(COUNT=0; COUNT<=3;COUNT++){
     var TheTextField = 'document.form.textfield_' + COUNT + '.value';
     if(TheTextField == ""){
       return false;
     }
   }

   Since the 3 field above have almost the same name I tried to write 
the  above code.
   Yes, I know this is not going to work. But, what should be the 
working code based on the code above? Can I have any examples?

   Thank you all,
   Fábio Gomes
-- 
@_{2**2..6*6}=split//,"aiGsDDbooe  eoin m-IsvveoF Tenlmt";print 
values%_,"\n"



More information about the thelist mailing list