Ask Experts Questions for FREE Help !
Ask
    dendenny01's Avatar
    dendenny01 Posts: 5, Reputation: 1
    New Member
     
    #1

    Mar 12, 2012, 09:04 PM
    Please Explain me the for loop of ASP
    <% @ language="VBScript" %>
    <% Option Explicit %>
    <html>
    <body>
    <%
    Dim I,j
    For I = 1 to 4
    For j = 1 to I
    Response.write I
    Next
    Response.write "<br>"
    Next
    </body>
    </html>

    Output:
    1
    22
    333
    4444

    Please explain me how this output is formed.
    indya's Avatar
    indya Posts: 357, Reputation: 58
    Full Member
     
    #2

    Mar 13, 2012, 12:22 AM
    The program here works on the concept of Nested Loops which means a loop within a loop.

    So, here loop 1 is For I = 1 to 4 within which is our loop 2 For j = 1 to i

    The loops will be executed as follows:

    1. i will be assigned the value 1 as loop one begins thus, i = 1
    2. j also will be assigned the value 1, j = 1
    3. Then we enter the Response.write i
      Next
      Response.write "<br>"
      Next
      where value of i will be written. Thus the out put is:
      1
    4. The execution goes back to check the inner loop, where the limit is j = 1 to i. Since i = 1, the inner loop ends and the first looping of the first loop ends too.
    5. Now, we execute the first loop again, as i = 2.
    6. Again the inner loop is executed, this time j = 1
    7. The value of i is printed as 2
    8. The execution goes back to inner loop again, to satisfy the condition j = 1 to 2, j takes the value 2, thus j = 2
    9. The inner loop is executed again, forming the output
      1
      22
    10. Same is followed of the values 3 and 4.


    In nested loop, if the outer looping is say of 10 times and the inner looping is 5, the total times the outer loop is executed will be 10 times, and the total times the inner loop is executed will 5X10 = 50 times.
    dendenny01's Avatar
    dendenny01 Posts: 5, Reputation: 1
    New Member
     
    #3

    Mar 13, 2012, 07:12 AM
    Thanxx Indya you saved my day..
    dendenny01's Avatar
    dendenny01 Posts: 5, Reputation: 1
    New Member
     
    #4

    Mar 24, 2012, 10:19 PM
    How can I transfer the Text value of form to radio button on submit or on click
    indya's Avatar
    indya Posts: 357, Reputation: 58
    Full Member
     
    #5

    Mar 25, 2012, 10:35 PM
    Not clear about what you are asking. I am assuming that you need to assign a user entered text value to a radio button.

    Just use the text property of the textbox and radiobutton to do so.

    radiobutton.text = textbox.text


Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

I am very needing yours about asp [ 2 Answers ]

Hi, I am VIetnammes I am studying informatic technonogy. I am studying shopping cart, I downed this demo ones is acart2_0 , but I have problem in error. In eacht pages that have SQL inner join that it don't run this code example <%@ LANGUAGE = "VBScript" %> <!-- #include file="db.asp" -->...

Asp or jsp? [ 5 Answers ]

I am doing a project at college. I am wondering if I should use asp or jsp. Any ideas? Thanks.


View more questions Search