hnEE
asked on
Concatenate response.write statements
Hi Experts
We have the following code that outputs the correct information in the browser. What is the best way (with example please) to turn this into one complete variable.
Thanks for your time.
We have the following code that outputs the correct information in the browser. What is the best way (with example please) to turn this into one complete variable.
Thanks for your time.
<%
While (NOT WA_eCart_EOF(GSDeCart))
Response.Write(WA_eCart_DisplayInfo(GSDeCart, "Quantity"))
Response.Write("x ")
Response.Write(WA_eCart_DisplayInfo(GSDeCart, "Description"))
Set GSDeCart = WA_eCart_MoveNext(GSDeCart)
If NOT WA_eCart_EOF(GSDeCart) Then
Response.Write(", ")
Else
Response.Write(".")
End If
Wend
%>
small correction:
Dim next_character
next_character = ""
While (NOT WA_eCart_EOF(GSDeCart))
Response.Write(WA_eCart_DisplayInfo(GSDeCart, "Quantity") & "x " & WA_eCart_DisplayInfo(GSDeCart, "Description" & next_character)
next_character = ","
Wend
Response.Write(".")
ASKER
Hi Experts
I may not have explained myself correctly.
The code in our example works correctly. It shows in the browsers exactly what it should. However, say it renders out "1x Dog, 2x Cat."
We would like to turn that output into a variable:
myVar = "1x Dog, 2x Cat."
I hope this make is clearer.
Thanks for your time
I may not have explained myself correctly.
The code in our example works correctly. It shows in the browsers exactly what it should. However, say it renders out "1x Dog, 2x Cat."
We would like to turn that output into a variable:
myVar = "1x Dog, 2x Cat."
I hope this make is clearer.
Thanks for your time
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi angelIII
Your response was very close - but showed me the basic idea. This got us what we needed in the end. Does that look okay to you?
Thanks for your help
Your response was very close - but showed me the basic idea. This got us what we needed in the end. Does that look okay to you?
Thanks for your help
Dim result
Dim next_character
next_character = ", "
While (NOT WA_eCart_EOF(GSDeCart))
result = result & WA_eCart_DisplayInfo(GSDeCart, "Quantity") & "x " & WA_eCart_DisplayInfo(GSDeCart, "Description") & next_character
If WA_eCart_EOF(GSDeCart) Then
next_character = ", "
Else
next_character = "."
End If
Set GSDeCart = WA_eCart_MoveNext(GSDeCart)
Wend
Set GSDeCart = WA_eCart_MoveFirst(GSDeCart)
Response.Write(result)
not wrong.
but not optimal :)
check out the stringbuilder class to reduce the string concatenation "overhead":
http://msdn.microsoft.com/en-us/library/ms972323.aspx
but not optimal :)
check out the stringbuilder class to reduce the string concatenation "overhead":
http://msdn.microsoft.com/en-us/library/ms972323.aspx
While (NOT WA_eCart_EOF(GSDeCart))
Response.Write(WA_eCart_Di