Help with loop

Results 1 to 2 of 2

Thread: Help with loop

  1. #1
    LoopMan Guest

    Default Help with loop

    I have 10 checkboxes. Name Interest0 - Interest9. I want to loop through all 10, find the ones that have been checked and add the value to an array. Then write out the results as the following. Interest0 = thevaluehere & Interest1 = empty....<BR>My feable attemp is below<BR>Thank you<BR><BR>for (i=0; i&#060; 14; i++){<BR> if (document.form1.Interesti.checked){<BR> Interest[i]=document.form1.Interest(i).value<BR> alert(Interest+i)<BR> }<BR>}

  2. #2
    Arky Guest

    Default RE: Help with loop

    Close but your way off.<BR><BR>its an easy fix though<BR><BR>do this<BR><BR>if you have<BR>checkbox1<BR>checkbox2<BR>checkbox3<BR><BR >var T_F = eval("document.form1.checkbox"+i+".checked")<BR><B R>the eval() will EVALUATE the stuff in it first and then T_F will give you the value your looking for.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts