Treder
asked on
response.write and include file?
Hi,
I am trying to adapt a script which was originally used to see if an image name matches a variable within a specific folder, if it does then the image is displayed, if not then a default image is displayed. I need to do a similar thing, but this time I am displaying different (html) text. I thought about doing it with the html text in little include asp files but I am not sure if it works with the script. Could someone take a look for me and advise.
<%
' See if there is a brand string in var level2 and that matches a brand description
Set fs=Server.CreateObject("Sc ripting.Fi leSystemOb ject")
if prodrs("p_level2") <> "" then
if fs.fileexists(server.mappa th("includ es/" & server.urlencode(prodrs("p _level2")) & ".asp")) then
response.write "<!-- #INCLUDE FILE=""includes/" & server.urlencode(prodrs("p _level2")) & ".asp"">"
else
response.write "<!-- #INCLUDE FILE=""includes/default.as p"">"
end if
else
response.write "<!-- #INCLUDE FILE=""includes/default.as p"">"
end if
set fs=nothing
%>
Many thanks,
Tony
I am trying to adapt a script which was originally used to see if an image name matches a variable within a specific folder, if it does then the image is displayed, if not then a default image is displayed. I need to do a similar thing, but this time I am displaying different (html) text. I thought about doing it with the html text in little include asp files but I am not sure if it works with the script. Could someone take a look for me and advise.
<%
' See if there is a brand string in var level2 and that matches a brand description
Set fs=Server.CreateObject("Sc
if prodrs("p_level2") <> "" then
if fs.fileexists(server.mappa
response.write "<!-- #INCLUDE FILE=""includes/" & server.urlencode(prodrs("p
else
response.write "<!-- #INCLUDE FILE=""includes/default.as
end if
else
response.write "<!-- #INCLUDE FILE=""includes/default.as
end if
set fs=nothing
%>
Many thanks,
Tony
ASKER
Many thanks for the reply.
Yes, I read up a bit about the include processing. Will give it a go and report back
Yes, I read up a bit about the include processing. Will give it a go and report back
ASKER
I guess I could do something like this:
...
if prodrs("p_level2") = "producta" then %>
<td> product a text </td>
<%
else if prodrs("p_level2") = "productb" then
%>
<td> product b text </td>
<%
else
%>
<td> default text </td>
<%
end if
Would that be sensible??
set fs=nothing
%>
...
if prodrs("p_level2") = "producta" then %>
<td> product a text </td>
<%
else if prodrs("p_level2") = "productb" then
%>
<td> product b text </td>
<%
else
%>
<td> default text </td>
<%
end if
Would that be sensible??
set fs=nothing
%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
please note that in your case you have one missing end if
the syntax of if statements is:
if condition then
'statement1
elseif condition2 then 'else and if are attached together no space between them
'statement2
elseif condition3 then
'statement3
else
'statement 4
end if
cheers,
dan
the syntax of if statements is:
if condition then
'statement1
elseif condition2 then 'else and if are attached together no space between them
'statement2
elseif condition3 then
'statement3
else
'statement 4
end if
cheers,
dan
ASKER
Dear hongjun,
Either you guys are ultra-tidy or I am a bit slack... I have not yet had a chance to look at all the suggested solutions, which of course I need to do before I can allocate points appropriately.
I am sorry to the posters if they feel I have taken too long and I really appreciate the ideas put forward.
I will allocate points now based on a brief run through.
Many thanks all,
Tony
Either you guys are ultra-tidy or I am a bit slack... I have not yet had a chance to look at all the suggested solutions, which of course I need to do before I can allocate points appropriately.
I am sorry to the posters if they feel I have taken too long and I really appreciate the ideas put forward.
I will allocate points now based on a brief run through.
Many thanks all,
Tony
ASKER
Sorry - that will teach me... In my haste I thought this was the cleanup of a newer post.
... please ignore my previous post.
... please ignore my previous post.
<%
' See if there is a brand string in var level2 and that matches a brand description
Set fs=Server.CreateObject("Sc
if prodrs("p_level2") <> "" then
if fs.fileexists(server.mappa
%>
<!-- #INCLUDE FILE=""includes/" & server.urlencode(prodrs("p
<%
else
%>
<!-- #INCLUDE FILE=""includes/default.as
<%
end if
else
%>
<!-- #INCLUDE FILE=""includes/default.as
<%
end if
set fs=nothing
%>