Nested If Statements

Results 1 to 3 of 3

Thread: Nested If Statements

  1. #1
    Hot Lips Guest

    Default Nested If Statements

    What is the proper way to nest these If&#039;s?<BR><BR>Here is what I need to do:<BR><BR>For each checkmark, if checked, increase count by 1<BR>If all checkmarks are checked, then<BR>show alert<BR>show next message (do you want to delete)<BR>if yes, delete<BR>else<BR>do nothing<BR><BR>function DelItems(){<BR>var total = 0;<BR>var max = DeleteItems.Delete.length; <BR>for (var idx = 0; idx &#060; max; idx++){ <BR>if (eval("document.DeleteItems.Delete[" + idx + "].checked") == true){ <BR> total += 1;//INCREASE TOTAL BY 1<BR> <BR><BR> }<BR>}<BR>if (eval(total==max))<BR> alert("You selected " + total + " boxes.");<BR> <BR> } <BR><BR>if (confirm("Do you want to delete the selected items?")){<BR>document.DeleteItems.action = "deleteboxitems.asp?&#060;%=sq%&#062;";<BR>documen t.DeleteItems.submit();<BR> <BR> else{<BR> return false;<BR>

  2. #2
    Cold Shoulders Guest

    Default How can *WE* know?

    Your code looks basically fine. <BR><BR>It follows the way you wrote the conditions.<BR><BR>Now, I *SUSPECT* that you didn&#039;t write the conditions correctly, so of course you didn&#039;t write the code correctly.<BR><BR>Ever heard of "indenting" code? To indicate what pieces go together?<BR><BR>IF user checked all boxes <BR>&nbsp; &nbsp; issue message to that effect<BR>&nbsp; &nbsp; ask if he/she wants to delete<BR>&nbsp; &nbsp; IF answer is yes<BR>&nbsp; &nbsp; &nbsp; &nbsp; delete<BR>&nbsp; &nbsp; End If<BR>End If<BR><BR>Is *THAT* more what you want???<BR><BR>If you will rewrite, using indents, then writing the code to match will be trivial.<BR><BR>

  3. #3
    Hot Lips Guest

    Default RE: How can *WE* know?

    Well, yes and no. There are two messages they can potentially appear. If user checked all boxes, then he/she will see the forst and second message. If not, he/she will only see the second message. And yes, I have heard of indenting code - I just posted it screwy!<BR><BR>IF user checked all boxes <BR> issue message to that effect<BR> ask if he/she wants to delete<BR> IF answer is yes<BR> delete<BR> End If<BR>End If<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