ASP variables?
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > IIS server support > IIS ASP > ASP variables?




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    ASP variables?  
thefunnel@aol.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-19-06 06:22 PM

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






[ Post a follow-up to this message ]



    Re: ASP variables?  
Turkbear


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-19-06 06:22 PM

On 19 Jun 2006 08:01:54 -0700, thefunnel@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..







[ Post a follow-up to this message ]



    Re: ASP variables?  
Lee Carnell


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-19-06 06:22 PM

Turkbear wrote:
> On 19 Jun 2006 08:01:54 -0700, thefunnel@aol.com wrote:
> 
>
> 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.







[ Post a follow-up to this message ]



    Re: ASP variables?  
Anthony Jones


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-19-06 06:22 PM


<thefunnel@aol.com> wrote in message
news:1150729314.360868.124140@f6g2000cwb.googlegroups.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" />









[ Post a follow-up to this message ]



    Re: ASP variables?  
Adrienne Boswell


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-20-06 12:25 PM

Gazing into my crystal ball I observed "Anthony Jones"
<Ant@yadayadayada.com> writing in
news:eP#gMt7kGHA.1320@TK2MSFTNGP04.phx.gbl:

>
><thefunnel@aol.com> wrote in message
> news:1150729314.360868.124140@f6g2000cwb.googlegroups.com... 
>
> 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






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:43 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register