...

View Full Version : js for a date month year form



delgado
09-06-2008, 01:30 PM
Hello to everyone
I am working in a form which has 3 inputs (Day Month Year) and a submit button.I dont know how to make the submit button load a single page, so that every time having different images (depending from the exact date)! I dont know if thats possible because i dont want to load my server with 200 (as many are my dates) different pages! I cant imagine a js that would do that

Thanks in advance

Philip M
09-06-2008, 06:44 PM
In principle you want something like this, where your images are named day1.jpg, day2.jpg, day3.jpg ... and so on up to day366.jpg.


<script type = "text/javascript">
Date.prototype.getDOY = function() {
var onejan = new Date(this.getFullYear(),0,1);
return Math.ceil((this - onejan) / 86400000);
}
var today = new Date();
var DOY = today.getDOY(); // returns xth day of year

alert (DOY); //delete after testing

document.write("<p align='center'><img src='day' + DOY + '.jpg' width=271 height=168 border= 0></p>");


</script>

BTW, the time to say "thanks" is afterwards, not beforehand which gives the impression that you take other people's unpaid assistance for granted. Or as British politician Neil Kinnock put it, "Don't belch before you have had the meal." Prefer to use "please" beforehand and if you find a response helpful then you can use the "Thank User For This Post" button.

delgado
09-06-2008, 10:28 PM
Ok Philip.....
Your comments was very interesting!
Unfortunately the code doesn t work! I ve tested with a jpg named day250 but it did nt load it!
Any idea what goes wrong?

Philip M
09-07-2008, 08:11 AM
Ok Philip.....
Your comments was very interesting!
Unfortunately the code doesn t work! I ve tested with a jpg named day250 but it did nt load it!
Any idea what goes wrong?

Well, it works fine for me. Is your image in the right directory?

delgado
09-07-2008, 07:46 PM
I am sorry but i cant fix it.
Could i do this?I have a link in the first page. Could i transform your code so that it would read the image name from the directory and load it in a second page. I want to do this for different link its time (which is the different date).lLoad the same page but with different image every time!
If so what would like the link in the first page?
<a href="index.html"+'nameoftheimage'> ??????

Philip M
09-08-2008, 08:18 AM
I am sorry but i cant fix it.
Could i do this?I have a link in the first page. Could i transform your code so that it would read the image name from the directory and load it in a second page. I want to do this for different link its time (which is the different date).lLoad the same page but with different image every time!
If so what would like the link in the first page?
<a href="index.html"+'nameoftheimage'> ??????

I am afraid that I do not really understand what you are trying to do.

My script will load a (different) image appropriate to the day of the year.
If you want something else you need to spell out clearly exactly what it is (and perhaps re-read my "interesting" comments).

delgado
09-08-2008, 09:38 AM
Hello
First of all accept my apologies if i confused you or made you nervous....it s my first time posting in a forum and i understand that you are trying to help without even knowing me....

I have 100 links in the first page!I want a script or something, so that when you press the first link, to read the name of the images from the directory and load the appropriate in a "second"page. I want to do this for every link, so that not have to load my server with 100 different pages, but load it with 100 images and 1 "second" page which would work as a template.Can you get it or i was nt clear enough again?

Thank you and i really appreciate your time spending for answering me.

Philip M
09-08-2008, 11:38 AM
Is this what you are after?


<a href="javascript:displayImage('http://YourSite.com/Image1.gif','500','400')">Image 1</a>
<a href="javascript:displayImage('http://Yoursite.com/Image2.gif','500','400')">Image 2</a>
<a href="javascript:displayImage('http://YourSite.com/Image3.gif','500','400')">Image 3</a>

<script type = "text/javascript">
var popWin = "";
function displayImage(url, strWidth, strHeight) {
if (popWin != "") {popWin.close()}
leftStr = (screen.width-strWidth)/2;
topStr = (screen.height-strHeight)/2-50;
windowProperties = "toolbar=no,menubar=no,scrollbars=no,statusbar=no,height="+strHeight+",width="+strWidth+",left="+leftStr+",top="+topStr+"";
displayImage = window.open(url,'newWin',windowProperties);
}
</script>

delgado
09-08-2008, 07:07 PM
Philip

That approach what i have in my mind....As you mentioned i am propably not good in giving you right directions in what exactly want but i thought that it would be easy for me to change your initial code to what exactly i want...!
Could you please guide me so that i would be able to load three images every time aligned verticaly, in a page that i could write whatever i want (or for eg put background color)?

Why i have to refresh my page in order to activate again your js to work????????

Please give me your opinion....

delgado
09-09-2008, 05:31 PM
Please response



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum