Jump to content

Image Manipulation


SuziQ63

Recommended Posts

I'm in charge of creating a JS Routine for the Web developer at index.shtml. Mr. Rhinesmith has asked me to create a routine which will automatically change the left corner graphic each month. The following is a snippet of code I am creating. Can anyone tell me if I am creating this code correctly? If I am not using the correct code could you tell me a resource I could use to get the correct code.SuziQ<script language="javascript" type="text/javascript"><!-- hide from non JavaScript browsersvar curImage = "October2_100x76";var ChangeGraphics;function rotate_graphic() { IF (curImage == "October2_100x76"); { document.graphics[0].src = "Novmber2_100x76"; (curImage = "October2_100x76"); ELSE document.graphics[0].src = "Novmber2_100x76.gif"; }}// - stop hiding -->}</SCRIPT>

Link to comment
Share on other sites

Um, I think you're on the right track. I would only suggest using an array to store your file names and then use the Date object to determine which file to display:

var files = new Array();files[0] = "January2_100x76.gif";files[1] = "February2_100x76.gif";// etc...files[11] = "December2_100x76.gif";var month = new Date().getMonth();// I'm not familiar with "document.graphics[0]" but...document.graphics[0].src = files[month];

Link to comment
Share on other sites

Um, I think you're on the right track. I would only suggest using an array to store your file names and then use the Date object to determine which file to display:
var files = new Array();files[0] = "January2_100x76.gif";files[1] = "February2_100x76.gif";// etc...files[11] = "December2_100x76.gif";var month = new Date().getMonth();// I'm not familiar with "document.graphics[0]" but...document.graphics[0].src = files[month];

Link to comment
Share on other sites

I'm in charge of creating a JS Routine for the Web developer at index.shtml. Mr. Rhinesmith has asked me to create a routine which will automatically change the left corner graphic each month. The following is a snippet of code I am creating. Can anyone tell me if I am creating this code correctly? If I am not using the correct code could you tell me a resource I could use to get the correct code.SuziQ<script language="javascript" type="text/javascript"><!-- hide from non JavaScript browsersvar curImage = "October2_100x76";var ChangeGraphics;function rotate_graphic() { IF (curImage == "October2_100x76"); { document.graphics[0].src = "Novmber2_100x76"; (curImage = "October2_100x76"); ELSE document.graphics[0].src = "Novmber2_100x76.gif"; }}// - stop hiding -->}</SCRIPT>
Link to comment
Share on other sites

You want something like:

<script type='text/javascript'>var Months = new Array();Months[0] = [ "January2_100x76.gif" , "Tagline here for January" ];Months[1] = [ "February2_100x76.gif" , "Tagline here for the month" ];Months[2] = [ "March2_100x76.gif" , "Tagline here for the month" ];Months[3] = [ "April2_100x76.gif" , "Tagline here for the month" ];//....Months[10] = [ "November2_100x76.gif" , "Tagline here for the month" ];Months[11] = [ "December2_100x76.gif" , "Tagline here for the month" ];var iMonth = new Date().getMonth()if(iMonth <= Months.length){	document.write( "<img src='" + Months[iMonth][0] + "' width='100' height='76' alt='" + Months[iMonth][1] + "' />")}</script>

... dropped in where the image would normally be on the page.Why aren't you doing it server side though? Seems pointless sending that code to every browser every page, when PHP could sort it out for you? Also, if a user sets a different date on their computer, they'll see a different month's message (obviously)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...