Ask Experts Questions for FREE Help !
Ask

Please Explain me the for loop of ASP

Asked Mar 12, 2012, 09:04 PM — 4 Answers
<% @ 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.

4 Answers
indya's Avatar
indya Posts: 361, Reputation: 322
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.
Helpful  (1)
dendenny01's Avatar
dendenny01 Posts: 5, Reputation: 10
Junior Member
 
#3

Mar 13, 2012, 07:12 AM
Thanxx Indya you saved my day..
Helpful
dendenny01's Avatar
dendenny01 Posts: 5, Reputation: 10
Junior 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
Helpful
indya's Avatar
indya Posts: 361, Reputation: 322
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

Helpful

Not your question? Ask your question View similar questions

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Add your answer here.

Remove Text Formatting

Undo
Redo
 
Decrease Size
Increase Size
Bold
Italic
Underline
Align Left
Align Center
Align Right
Ordered List
Unordered List
Decrease Indent
Increase Indent
Insert Email Link
Wrap [QUOTE] tags around selected text
Wrap [CODE] tags around selected text
Wrap [HTML] tags around selected text
Wrap [PHP] tags around selected text
Wrap [YOUTUBE] tags around selected text
Notification Type:



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 studing 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 ASP questions Search