Click to See Complete Forum and Search --> : select onchange option how to make it work on netscape
spaceplane
02-10-2003, 10:04 PM
I got a big problem I got a function that need to work on onchange
<SELECT name="FirstSelectMonth" onchange="ChangeOptionDays('FirstSelect');">
<OPTION>Jan
<OPTION>Fev
<OPTION>Mar
<OPTION>Avr
<OPTION>Mai
<OPTION>Jun
<OPTION>Jui
<OPTION>Aou
<OPTION>Sep
<OPTION>Oct
<OPTION>Nov
<OPTION>Dec
</SELECT>
on explorer it work but not on netscape how can I fix that
thanks
spaceplane
02-10-2003, 10:35 PM
Can you tell me what's wrong??? I don't use the value option on my code
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
//set todays date
Now = new Date();
NowDay = Now.getDate();
NowMonth = Now.getMonth();
NowYear = Now.getYear();
if (NowYear < 2000) NowYear += 1900; //for Netscape
//function for returning how many days there are in a month including leap years
function DaysInMonth(WhichMonth, WhichYear)
{
var DaysInMonth = 32;
if (WhichMonth == "Avr" || WhichMonth == "Jun" || WhichMonth == "Sep" || WhichMonth == "Nov") DaysInMonth = 31;
if (WhichMonth == "Fev" && (WhichYear/4) != Math.floor(WhichYear/4)) DaysInMonth = 29;
if (WhichMonth == "Fev" && (WhichYear/4) == Math.floor(WhichYear/4)) DaysInMonth = 30;
return DaysInMonth;
}
//function to change the available days in a months
function ChangeOptionDays(Which)
{
DaysObject = eval("document.Form1." + which + "Day");
MonthObject = eval("document.Form1." + Which + "Month");
YearObject = eval("document.Form1." + Which + "Year");
Month = MonthObject[MonthObject.selectedIndex].text;
Year = YearObject[YearObject.selectedIndex].text;
DaysForThisSelection = DaysInMonth(Month, Year);
CurrentDaysInSelection = DaysObject.length;
if (CurrentDaysInSelection > DaysForThisSelection)
{
for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
{
DaysObject.options[DaysObject.options.length - 1] = null;
}
}
if (DaysForThisSelection > CurrentDaysInSelection)
{
for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)
{
NewOption = new Option(DaysObject.options.length);
DaysObject.add(NewOption);
}
}
if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;
//partie qui me fait chier...
//here is the part that I'm trying to make work
if (document.Form1.FirstSelectYear.selectedIndex == document.Form1.EndSelectYear.selectedIndex)
{
if (document.Form1.FirstSelectMonth.selectedIndex == document.Form1.EndSelectMonth.selectedIndex)
{
if (document.Form1.FirstSelectDay.selectedIndex > document.Form1.EndSelectDay.selectedIndex)
{
document.Form1.EndSelectDay[document.Form1.FirstSelectDay.selectedIndex].selected = true;
}
}
else
{
if (document.Form1.FirstSelectMonth.selectedIndex > document.Form1.EndSelectMonth.selectedIndex)
{
document.Form1.EndSelectMonth[document.Form1.FirstSelectMonth.selectedIndex].selected = true;
document.Form1.EndSelectDay[document.Form1.FirstSelectDay.selectedIndex].selected = true;
}
}
}
else
{
if (document.Form1.FirstSelectYear.selectedIndex > document.Form1.EndSelectYear.selectedIndex)
{
document.Form1.EndSelectYear[document.Form1.FirstSelectYear.selectedIndex].selected = true;
document.Form1.EndSelectMonth[document.Form1.FirstSelectMonth.selectedIndex].selected = true;
document.Form1.EndSelectDay[document.Form1.FirstSelectDay.selectedIndex].selected = true;
}
}
//end of the part I'm having trouble with
//fin de la partie
}
//function to set options to today
function SetToToday(Which)
{
<?php
$REQUEST_METHOD="POST";
$AjouterEvenement=1;
if ($REQUEST_METHOD=="POST")
{
if ($AjouterEvenement==1)
{
echo " DaysObject = eval(\"document.Form1.\" + Which + \"Day\");\n";
echo " MonthObject = eval(\"document.Form1.\" + Which + \"Month\");\n";
echo " YearObject = eval(\"document.Form1.\" + Which + \"Year\");\n";
echo " YearObject[0].selected = true;\n";
echo " MonthObject[NowMonth].selected = true;\n";
echo " ChangeOptionDays(Which);\n";
echo " DaysObject[NowDay].selected = true;\n";
}
if ($ModifierEvenement==1)
{
echo " document.Form1.FirstSelectYear[".(((int)$FirstSelectYear)-((int)date(Y)))."].selected = true;\n";
echo " document.Form1.FirstSelectMonth[".$FirstSelectMonth."].selected = true;\n";
echo " document.Form1.FirstSelectDay[".$FirstSelectDay."].selected = true;\n";
echo " document.Form1.EndSelectYear[".(((int)$EndSelectYear)-((int)date(Y)))."].selected = true;\n";
echo " document.Form1.EndSelectMonth[".$EndSelectMonth."].selected = true;\n";
echo " document.Form1.EndSelectDay[".$EndSelectDay."].selected = true;\n";
}
}
?>
}
//function to write option years plus x
function WriteYearOptions(YearsAhead)
{
line = "";
for (i=0; i<YearsAhead; i++)
{
line += "<OPTION>";
line += NowYear + i;
}
return line;
}
// End -->
</script>
spaceplane
02-11-2003, 11:52 AM
It's in changeOptionDays(which) function it work perfercly on explorer but doesn't work in netscape I post all the code so if you want to test it it's easier but the problem is for sure in that function and prbably from the start of that function to the middle where it's says //part.... cause if I put the first part in comment the rest of the code work perfectly in netscape i'm for sure the problem is in that part
if (CurrentDaysInSelection > DaysForThisSelection)
{
for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)
{
DaysObject.options[DaysObject.options.length - 1] = null;
}
}
if (DaysForThisSelection > CurrentDaysInSelection)
{
for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)
{
DaysObject.add(new Option(DaysObject.options.length + 1));
}
}
if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex = 0;
thanks for everything you really helping me already but now I'M lost completely
thanks
spaceplane
02-11-2003, 01:37 PM
I was having problem with adding stuff to my select in jnetscape or in explorer
I got to do that:
var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);
var NSX = (navigator.appName == "Netscape");
var IE4 = (document.all) ? true : false;
if (NSX)
{
var newOpt = new Option(DaysObject.options.length);
var selLength = DaysObject.length;
DaysObject.options[selLength] = newOpt;
if (NS4) history.go(0);
}
else if (IE4)
{
DaysObject.add(new Option(DaysObject.options.length));
}
thanks for all your help