Click to See Complete Forum and Search --> : need to code .gif to pop up please help


Raven
11-13-2003, 11:11 AM
This script will calculate the day of someones birth, but instead of a window popping up with text, I would like to have specified images that corrospond with each day of the week pop up instead. In the red area is where is tells what text to popup with. I have tried several things here to try to make it see an image instead such as <img src="http.your.gif"> but I get scrip error or "http:your.gif" but it simply writes http:your.gif on the screen. This below is the <head> part of the script, I am pretty sure this is the one I want to change but if you need to see the <body> part please e-mail me raven@ecdollz.com and I will send it to you.




<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
function calculate() {
month = document.form.month.selectedIndex;
month = document.form.month.options[month].value;
day = document.form.day.selectedIndex;
day = document.form.day.options[day].value;
year = document.form.year.value;

var oyear=year

var dob = " "+ year +", "+month + ", "+day;
var thenx = new Date(dob);

var year=thenx.getYear();
if (year<100) year="19" + thenx.getYear();
else year=thenx.getYear();

if (year > 1969) wyear=year;
else {
if (oyear<1900) {
if (oyear>1800) {
wrelyear= (eval(oyear)-1801)%(28);
wyear = wrelyear+1981;
}
else wyear = 1970
}
else
if (oyear>1900) {wrelyear= (eval(oyear)-1901)%(28);
wyear= wrelyear+1985
}
else
if (oyear==1900) {wyear= 1990;
}
}
var dob = " "+ wyear +", "+month + ", "+day;
var thenx = new Date(dob);

var theday = thenx.getDay()+1;
var date=thenx.getDate();

var weekday = new Array(6);

weekday[1]="But A Child That's Born On The Sabbath Day Is Bonny And Blithe, And Good And Gay";
weekday[2]="Monday's Child is Fair of Face";
weekday[3]="Tuesday's Child Is Full Of Grace";
weekday[4]="Wednesday's Child Is Full Of Woe";
weekday[5]="Thursday's Child Has Far To Go";
weekday[6]="Friday's Child Is Loving And Giving";
weekday[7]="Saturday's Child Works Hard For A Living";


if (day != date) alert("Sorry! That appears to be an invalid date!"+day+" ..."+date+"::"+oyear+"..."+year+" "+dob+"=="+wyear+".-.-"+thenx+" "+day+" "+month);
else {
dayborn = weekday[theday];
dob = dayborn ;
alert(" " + dob);
}

}
// End -->
</script>

Shampie
11-13-2003, 01:07 PM
You cannot have the image popup in an alert window that is why it will write it..

dayborn = weekday[theday];
dob = dayborn ;
alert(" " + dob);


weekday[1]="Sunday";
weekday[2]="Monday";
weekday[3]="Tuesday";
weekday[4]="Wednesday";
weekday[5]="Thursday";
weekday[6]="Friday";
weekday[7]="Saturday";


dayborn = weekday[theday];
dob = dayborn ;
document.write("<img src="+dob+".gif>");


when theday = 1 -> the pic will be Sunday.gif (remember to name the pic Sunday.gif and not sunday.gif)

Raven
11-13-2003, 04:28 PM
oh I copied it exactly and pasted it on over this part here




weekday[1]="But A Child That's Born On The Sabbath Day Is Bonny And Blithe, And Good And Gay";
weekday[2]="Monday's Child is Fair of Face";
weekday[3]="Tuesday's Child Is Full Of Grace";
weekday[4]="Wednesday's Child Is Full Of Woe";
weekday[5]="Thursday's Child Has Far To Go";
weekday[6]="Friday's Child Is Loving And Giving";
weekday[7]="Saturday's Child Works Hard For A Living";


if (day != date) alert("Sorry! That appears to be an invalid date!"+day+" ..."+date+"::"+oyear+"..."+year+" "+dob+"=="+wyear+".-.-"+thenx+" "+day+" "+month);
else {
dayborn = weekday[theday];
dob = dayborn ;
alert(" " + dob);
}

}



and I copied , pasted and changed this line accordingly

when theday = 1 -> the pic will be Sunday.gif

but I get script errors still and the .gif's don't show.. I renamed them all after the days making sure to have 1st letter capital.. any idea what I did wrong?

Shampie
11-14-2003, 03:00 PM
PM the full page and I will have a look trough it ok?