473,487 Members | 2,622 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ASP variables?

Hi,

I have the following ASP to display a certain image depending on a case
statement...

<%
Select Case (recordset("type"))
Case "type1"
Response.Write ("<img src=""type1.gif"" border=""0"">")
Case "type2"
Response.Write ("<img src=""type2.gif"" border=""0"">")
Case "type"
Response.Write ("<img src=""type3.gif"" border=""0"">")
End Select
%>

As the case section will be the same through out the document, and will
appear up to 30 times... Can I create some kind of "variable" at the
top and simply call it when required?

Many thanks,

Paul

Jun 19 '06 #1
5 1163
On 19 Jun 2006 08:01:54 -0700, th*******@aol.com wrote:
Hi,

I have the following ASP to display a certain image depending on a case
statement...

<%
Select Case (recordset("type"))
Case "type1"
Response.Write ("<img src=""type1.gif"" border=""0"">")
Case "type2"
Response.Write ("<img src=""type2.gif"" border=""0"">")
Case "type"
Response.Write ("<img src=""type3.gif"" border=""0"">")
End Select
%>

As the case section will be the same through out the document, and will
appear up to 30 times... Can I create some kind of "variable" at the
top and simply call it when required?

Many thanks,

Paul


Perhaps yu can write it as a Subroutine and call it when needed..
Jun 19 '06 #2
sashi
1,754 Recognized Expert Top Contributor
Hi Paul,

emm.. i think using case is to simply coding method.. emm.. let me see.. u want to further simplify it eh.. emm.. why not try using while loop.. well.. since your graphic file name ends up with an integer.. "typeN.gif".. you can use while loop with an increment counter method.. u know.. some thing like

<%
while not nType
..
nType = nType = 1 untill nType = 30 .. this is just to give you some basic idea..
..
loop
%>

try it.. change the code n post the changes.. will help to check it for you.. good luck..

you know what Paul.. i hate to write program for ppl.. but, instead i love to help them to troubleshoot their code.. :) so.. give it a try n come back later.. good luck buddy..
Jun 19 '06 #3
Turkbear wrote:
On 19 Jun 2006 08:01:54 -0700, th*******@aol.com wrote:
Hi,

I have the following ASP to display a certain image depending on a
case statement...

<%
Select Case (recordset("type"))
Case "type1"
Response.Write ("<img src=""type1.gif"" border=""0"">")
Case "type2"
Response.Write ("<img src=""type2.gif"" border=""0"">")
Case "type"
Response.Write ("<img src=""type3.gif"" border=""0"">")
End Select
%>

As the case section will be the same through out the document, and
will appear up to 30 times... Can I create some kind of "variable"
at the top and simply call it when required?

Many thanks,

Paul


Perhaps yu can write it as a Subroutine and call it when needed..

How about this....

Dim strImage
Select Case (recordset("type"))
Case "type1"
strImage = "<img src=type1.gif border=0 />"
Case "type2"
strImage = "<img src=type2.gif border=0 />"
Case "type"
strImage = "<img src=type3.gif border=0 />"
End Select

Then to display the image in the page just response.write strImage at the
appropraite point.
--
--
Lee Carnell
Never enter a place you can't run out of.
Jun 19 '06 #4

<th*******@aol.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.com...
Hi,

I have the following ASP to display a certain image depending on a case
statement...

<%
Select Case (recordset("type"))
Case "type1"
Response.Write ("<img src=""type1.gif"" border=""0"">")
Case "type2"
Response.Write ("<img src=""type2.gif"" border=""0"">")
Case "type"
Response.Write ("<img src=""type3.gif"" border=""0"">")
End Select
%>

As the case section will be the same through out the document, and will
appear up to 30 times... Can I create some kind of "variable" at the
top and simply call it when required?

Many thanks,

Paul


What you need is a Function:-

Function GetTypeImg(rsType)

Select Case
Case "type1": GetTypeImg = "type1.gif"
Case "type2": GetTypeImg = "type2.gif"
Case "type3": GetTypeImg = "type3.gif"
End Select

End Function

At the point in the HTML where you want the img:-

<img src="<%=GetTypeImg(rst("type"))%>" border="0" />


Jun 19 '06 #5
Gazing into my crystal ball I observed "Anthony Jones"
<An*@yadayadayada.com> writing in
news:eP**************@TK2MSFTNGP04.phx.gbl:

<th*******@aol.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.com...
Hi,

I have the following ASP to display a certain image depending on a
case statement...

<%
Select Case (recordset("type"))
Case "type1"
Response.Write ("<img src=""type1.gif"" border=""0"">")
Case "type2"
Response.Write ("<img src=""type2.gif"" border=""0"">")
Case "type"
Response.Write ("<img src=""type3.gif"" border=""0"">")
End Select
%>

As the case section will be the same through out the document, and
will appear up to 30 times... Can I create some kind of "variable" at
the top and simply call it when required?

Many thanks,

Paul


What you need is a Function:-

Function GetTypeImg(rsType)

Select Case
Case "type1": GetTypeImg = "type1.gif"
Case "type2": GetTypeImg = "type2.gif"
Case "type3": GetTypeImg = "type3.gif"
End Select

End Function

At the point in the HTML where you want the img:-

<img src="<%=GetTypeImg(rst("type"))%>" border="0" />


I would remove border="0" to CSS [img {border:0}] and put in alt="".

--
Adrienne Boswell at Home
Arbpen Web Site Design Services
http://www.cavalcade-of-coding.info
Please respond to the group so others can share

Jun 20 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4892
by: Hal Vaughan | last post by:
First, I am aware of both SwingUtilities.invokeLater(), and of using Thread to create a new thread.  These are part of the problem. I want to have something running in the background, while the...
4
1603
by: Torsten Bronger | last post by:
Hallöchen! I have a file that looks a little bit like a C header file with a long list of variables (actually constants) definitions, e.g. VI_ATTR_TIMO = 0x54378 .... Actually I need this...
1
4331
by: mark4asp | last post by:
What are the best methods for using global constants and variables? I've noticed that many people put all global constants in a file and include that file on every page. This is the best way of...
5
3305
by: Ross A. Finlayson | last post by:
Hi, I'm scratching together an Access database. The development box is Office 95, the deployment box Office 2003. So anyways I am griping about forms and global variables. Say for example...
7
3102
by: Michael | last post by:
Hi newsgroup, as the subject indicates I am looking for an advice using global variables. I am not if this problem is more about style then C. If its wrong in thi group, sorry. So I have a...
9
8608
by: CDMAPoster | last post by:
About a year ago there was a thread about the use of global variables in A97: http://groups.google.com/group/comp.databases.ms-access/browse_frm/thread/fedc837a5aeb6157 Best Practices by Kang...
7
13661
by: misha | last post by:
Hello. I was wandering if someone could explain to me (or point to some manual) the process of mapping the addresses of host variables by DB2. Especially I would like to know when DB2 decides to...
5
11795
by: Sandman | last post by:
I dont think I understand them. I've read the section on scope in the manual inside out. I'm running PHP 5.2.0 Here is the code I'm working on: //include_me.php <?php $MYVAR = array(); global...
1
29295
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have...
4
2361
by: icarus | last post by:
global_vars.py has the global variables set_var.py changes one of the values on the global variables (don't close it or terminate) get_var.py retrieves the recently value changed (triggered right...
0
7106
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7181
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5442
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4874
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3076
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1381
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
267
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.