Hi,
My name is Tristine. I have the existing javascript code with has no default year. I need to set a default year for it. Please look at the code below and advise me how I need to write the default year.
thanks.
function setContractList() //Set Contract List dependent upon mrt
{
index = 0;
ii = document.form1.contract_year.selectedIndex;
year = document.form1.contract_year.options[ii].value;
obj = document.form1.contract_id;
obj.options.length = 1; // Set length back to first blank line
k=1;
for(j = 0; j < termArray.length; j++)
{
if ((effectArray[j] <= year || effectArray[j] == null || effectArray[j] == "") && (termArray[j] >= year || termArray[j] == null || termArray[j] == ""))
{
obj.options[k] = new Option(optionTxt[j], optionVal[j], false, false); // no defaults set
k++;
}
}
if(obj.options.length != 0) obj.options[0].selected = true; // Blank value is default selection
}
If you would like to default to the current year then you can just use code similar to this:
Code:<script type="text/javascript"> var d = new Date(); var curr_date = d.getDate(); var curr_month = d.getMonth(); var curr_year = d.getFullYear(); </script>
-CDG10620
Software Developer
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks