Change pics related to date


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: Change pics related to date

  1. #1
    Join Date
    Nov 2005
    Posts
    3

    Arrow 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

  2. #2
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    255
    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.

  3. #3
    Join Date
    Nov 2005
    Posts
    3

    Wink

    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

  4. #4
    Join Date
    Oct 2005
    Posts
    107
    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 04:57 PM.

  5. #5
    Join Date
    Oct 2005
    Location
    New Jersey
    Posts
    255

    Unhappy Java != JavaScript

    Quote 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.

  6. #6
    Join Date
    Nov 2005
    Posts
    3
    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

  1. using asp/fso OR(any) to change file date
    By Micke in forum ASP.NET
    Replies: 0
    Last Post: 06-20-2002, 01:18 PM
  2. Replies: 2
    Last Post: 06-29-2001, 12:16 PM
  3. PC date change from an Input Box
    By Kef in forum VB Classic
    Replies: 0
    Last Post: 07-06-2000, 03:36 PM
  4. Date Change from Input Box
    By Keflavik in forum VB Classic
    Replies: 0
    Last Post: 07-03-2000, 12:28 PM
  5. Change Date Settings
    By Ghislain in forum VB Classic
    Replies: 0
    Last Post: 03-29-2000, 02: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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center