-
Change pics related to date
I want to change a certain pic on my website.
It's the logo wich i want to change, for X-mas, Halloween.
In VB-script its something like this:
<%@ Language=VBScript %>
<%
Dim strFoto
strFoto="http://www.shipinfo.nl/test/Logo.gif"
if format(now,"mmdd") > "1101" and format(now,"mmdd") < "1206" then
strFoto="http://www.shipinfo.nl//test/Logo_SK.gif"
endif
if format(now,"mmdd") >= "1206" and format(now,"mmdd") < "1226" then
strFoto="http://www.shipinfo.nl//test/Logo_Xmas.gif"
end if
if format(now,"mmdd") >= "1227" and format(now,"mmdd") < "0105" then
strFoto="http://www.shipinfo.nl//test/Logo_NY.gif"
end if
if format(now,"mmdd") >= "0106" and format(now,"mmdd") < "0216" then
strFoto="http://www.shipinfo.nl//test/Logo_Car.gif"
end if
if format(now,"mmdd") >= "0217" and format(now,"mmdd") < "0326" then
strFoto="http://www.shipinfo.nl//test/Logo_Eastern.gif"
end if
%>
<img src="<%=strFoto%>">
I always have to depend if the webserver is able to use ASP
Does anyone know how to do this in java, and show me an example ?
Kind regards Skippy
-
I suppose you are talking of JSP, it should look something like this:
Code:
<%@ page language="Java" %>
<%@ page import="java.util.Date"%>
<%@ page import="java.text.SimpleDateFormat"%>
<%
// NOT following Java coding conventions :)
String strFoto = "http://www.shipinfo.nl/test/Logo.gif";
Date date = new Date(); // Equivalent of "now"
SimpleDateFormat sdf = new SimpleDateFormat("MMdd");
String strFormatDt = sdf.format(date);
if((strDateFormat.compareTo("1101") >= 0) && (strDateFormat.compareTo("1206") < 0))
strFoto="http://www.shipinfo.nl//test/Logo_SK.gif";
else if((strDateFormat.compareTo("1206") >= 0) && (strDateFormat.compareTo("1226") < 0))
strFoto="http://www.shipinfo.nl//test/Logo_Xmas.gif";
else if((strDateFormat.compareTo("1227") > 0) || (strDateFormat.compareTo("0105") < 0)) {
strFoto="http://www.shipinfo.nl//test/Logo_NY.gif";
} else if((strDateFormat.compareTo("0106") >= 0) && (strDateFormat.compareTo("0216") < 0))
strFoto="http://www.shipinfo.nl//test/Logo_Car.gif";
else if((strDateFormat.compareTo("0217") >= 0) && (strDateFormat.compareTo("0326") < 0))
strFoto="http://www.shipinfo.nl//test/Logo_Eastern.gif";
%>
...
<img src="<%=strFoto%>">
Of course, I have used a crude manipulation to compare the dates. There would be a better way of achieving this.
Happiness is good health and a bad memory.
-
Thx my friend for your quick respons.
Unfortunattly it's not working, i changed to path into the correct ways but it's not running.
<%@ page language="Java" %>
<%@ page import="java.util.Date"%>
<%@ page import="java.text.SimpleDateFormat"%>
<%
// NOT following Java coding conventions 
String strFoto = "http://www.shipinfo.nl/Green_bar_Logo.gif";
Date date = new Date(); // Equivalent of "now"
SimpleDateFormat sdf = new SimpleDateFormat("MMdd");
String strFormatDt = sdf.format(date);
if((strDateFormat.compareTo("1101") >= 0) && (strDateFormat.compareTo("1206") < 0))
strFoto="http://www.shipinfo.nl//test/images/Green_bar_SK.gif";
else if((strDateFormat.compareTo("1206") >= 0) && (strDateFormat.compareTo("1226") < 0))
strFoto="http://www.shipinfo.nl//test/images/Green_bar_Xmas.gif";
else if((strDateFormat.compareTo("1227") > 0) || (strDateFormat.compareTo("0105") < 0)) {
strFoto="http://www.shipinfo.nl//test/Logo_NY.gif";
} else if((strDateFormat.compareTo("0106") >= 0) && (strDateFormat.compareTo("0216") < 0))
strFoto="http://www.shipinfo.nl//test/Logo_Car.gif";
else if((strDateFormat.compareTo("0217") >= 0) && (strDateFormat.compareTo("0326") < 0))
strFoto="http://www.shipinfo.nl//test/Logo_Eastern.gif";
%>
<img src="<%=strFoto%>">
Maybe you have a clue why not?
Is JSP normally on every webserver, is it the same as javascript?
Kind regards Skippy
-
i think you want javascript. Embedded java is executed on the server, which won't work if you have an asp application. At least i think so. Correct me if i'm wrong.
Last edited by Joe Beam; 11-03-2005 at 03:57 PM.
-
Java != JavaScript
 Originally Posted by Skippy
Unfortunattly it's not working, i changed to path into the correct ways but it's not running.
...
Maybe you have a clue why not?
Is JSP normally on every webserver, is it the same as javascript?
No, JSP is not normally on every web server and it is not the same as Javascript. JSP has server side processing while JavaScript works on the client side.
The logic would be similar to what I typed but certainly not the same. Here's a nice JavaScript tutorial
Happiness is good health and a bad memory.
-
Indeed, i think the best would be javascript. It's not working in asp application.
It's just a website for a friend wich owns a gym. I justed wanted to change the logo for x-mas, eastern etc.
I try the tutorial, many thx all of you.
kind regards Skippy
Similar Threads
-
By Micke in forum ASP.NET
Replies: 0
Last Post: 06-20-2002, 12:18 PM
-
By Guillermo in forum Database
Replies: 2
Last Post: 06-29-2001, 11:16 AM
-
By Kef in forum VB Classic
Replies: 0
Last Post: 07-06-2000, 02:36 PM
-
By Keflavik in forum VB Classic
Replies: 0
Last Post: 07-03-2000, 11:28 AM
-
By Ghislain in forum VB Classic
Replies: 0
Last Post: 03-29-2000, 01:52 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks