Web Hosting Talk







View Full Version : for loop in asp


hoachen
03-03-2006, 02:29 PM
I want any textbox that filled with the children name will display on my email account. Can I use the for loop to do it? The bottom is not work!

Dim child
for child = 1 to 4
for each child in Request.Form("child_name")
then
message = messege & "Children Name: " & Request.Form(child)

end if


HTML
<input type="text" name="child_name" value="1"> Name 1:
<input type="text" name="child_name" value="2"> Name 2:
<input type="text" name="child_name" value="3"> Name 3:
<input type="text" name="child_name" value="4"> Name 4:

innova
03-03-2006, 03:30 PM
ASP insults its users:

Dim child

Ahaha.. Sorry to be offtopic, couldnt resist...

unlucky1
03-03-2006, 04:36 PM
Try this and let me know if it works...

dim children, child
children = split(Request.Form("child_name", ",")
for each child in children
message = messege & "Children Name: " & child
next

hoachen
03-03-2006, 04:45 PM
No it's not working. When I press submit the erro "The page cannot be displayed"

Try this and let me know if it works...

dim children, child
children = split(Request.Form("child_name", ",")
for each child in children
message = messege & "Children Name: " & child
next

SiliconWolf
03-04-2006, 03:06 AM
Sounds like you have a compiler error in your code. If you're using Internet Explorer as your browser, you won't be able to see it unless you turn off one of the default settings:

Tools menu -> Internet Options... -> Advanced tab -> uncheck "Show friendly HTTP error messages"

hoachen
03-04-2006, 09:37 AM
it is error 500 but when i took out the code that you provide then it is o.k. This means the syntax is not right. I have tried to take the correct code and alter it to different code it gave me the same error "page connot be display" and at the bottom page is http:error 500.





Sounds like you have a compiler error in your code. If you're using Internet Explorer as your browser, you won't be able to see it unless you turn off one of the default settings:

Tools menu -> Internet Options... -> Advanced tab -> uncheck "Show friendly HTTP error messages"

SiliconWolf
03-05-2006, 05:48 AM
I didn't post that code originally, but I did find a couple errors in it (a missing parenthesis and a misspelling -- the stuff in red):

Try this and let me know if it works...

dim children, child
children = split(Request.Form("child_name"), ",")
for each child in children
message = message & "Children Name: " & child
next


hoachen, the point I was trying to make is that if you turn off that setting in IE, then VBScript will spit out a more useful error message telling you what line of code the error happened on. Instead of "page cannot be displayed" you will see something like "Complier error on line 2: expected ')'". That tells you where to look to fix the problem.

See here: http://www.webwizguide.com/asp/faq/friendly_HTTP_error_messages.asp for screenshots of the setting. Remember that you need to turn it OFF, not on.

hoachen
03-06-2006, 10:52 AM
hey guest what! it works now. thank you for your patients and good advice.

Cheers,
hoachen


I didn't post that code originally, but I did find a couple errors in it (a missing parenthesis and a misspelling -- the stuff in red):




hoachen, the point I was trying to make is that if you turn off that setting in IE, then VBScript will spit out a more useful error message telling you what line of code the error happened on. Instead of "page cannot be displayed" you will see something like "Complier error on line 2: expected ')'". That tells you where to look to fix the problem.

See here: http://www.webwizguide.com/asp/faq/friendly_HTTP_error_messages.asp for screenshots of the setting. Remember that you need to turn it OFF, not on.

unlucky1
03-06-2006, 05:44 PM
Ooops yeah sorry for the syntax error.

hoachen
03-06-2006, 05:57 PM
I am cool, i know u try to help.

Ooops yeah sorry for the syntax error.