Javascript datepicker date

Changing a date picker from yyyy/mm/dd/ to dd/mm/yyyy

Page 1 of 1

9 Replies - 3497 Views - Last Post: 12 October 2009 - 09:30 AM

#1 bambinou  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 11-October 09

Javascript datepicker date

Post icon  Posted 11 October 2009 - 01:39 PM

Hello,

I am fairly new to Programming and have been struggling the whole week end with this problem, it might sound simple to you and do apologies in advance if it is.
I have a website using an interface called Oneadmin from Comdev, I have been on their website trying to get some help but they are not replying and their F.A.Qs are not mentioning my problem.
My full website has many date pickers all orientated to one Javascript file , this file is set to the american date format that is YYYY/MM/DD and I need to have DD/MM/YYYY instead, I believe the end of the file might have the answer because there is a line saying:
// datetime parsing and formatting routimes. modify them if you wish other datetime format

Here is the code:

var type_cal=0;
var web_root="http://www.MYSITENAME/oneadmin/"; //SITE IP


function get2DigitDate(dd)
{
	if(dd>=1 && dd<=9  )
	{
		return '0'+dd;
	}else
	{
		return dd;
	}
}
function get2DigitMonth(mm)
{
	if(mm>=1 && mm<=9  )
	{
		return '0'+mm;
	}else
	{
		return mm;
	}
}
function load_calendar(str_target, str_datetime) {
	var arr_months = ["January", "February", "March", "April", "May", "June",
		"July", "August", "September", "October", "November", "December"];
	var week_days = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
	var n_weekstart = 1; // day week starts from (normally 0 or 1)

	if(str_datetime == null || str_datetime =="" || str_datetime =="0000-00-00" || str_datetime =="0000/00/00")
	{
		get_date=new Date();
		
		if(str_datetime =="0000-00-00")
		{
			dd=get_date.getDate();
			dd=get2DigitDate(dd);
			mm=get_date.getMonth()+1;
			mm=get2DigitMonth(mm);
			yy=get_date.getFullYear();
			str_datetime=yy+'-'+mm+'-'+dd;
		}else if(str_datetime =="0000/00/00")
		{
			dd=get_date.getDate();
			dd=get2DigitDate(dd);
			mm=get_date.getMonth()+1;
			mm=get2DigitMonth(mm);
			yy=get_date.getFullYear();
			str_datetime=yy+'/'+mm+'/'+dd;
		}else
		{
			dd=get_date.getDate();
			dd=get2DigitDate(dd);
			mm=get_date.getMonth()+1;
			mm=get2DigitMonth(mm);
			yy=get_date.getFullYear();
			str_datetime=yy+'-'+mm+'-'+dd;
		}
	}
	var dt_datetime = (str_datetime == null || str_datetime =="" || str_datetime =="0000-00-00" ?  new Date() : str2dt(str_datetime) || str_datetime =="00/00/0000" ?  new Date() : str2dt(str_datetime));

	var dt_prev_month = new Date(dt_datetime);
	dt_prev_month.setMonth(dt_datetime.getMonth()-1);

	var dt_next_month = new Date(dt_datetime);
	dt_next_month.setMonth(dt_datetime.getMonth()+1);
	var dt_firstday = new Date(dt_datetime);
	dt_firstday.setDate(1);

	dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);
	var dt_lastday = new Date(dt_next_month);
	dt_lastday.setDate(0);
	

	// html generation (feel free to tune it for your particular application)
	// print calendar header
	var str_buffer = new String (
		"<html>\n"+
		"<head><title>Calendar</title></head>\n"+
		"<body style=\"background-color:transparent\">\n"+
		"<table class=\"clsOTable\" cellspacing=\"0\" cellspadding=\"0\" border=\"0\" width=\"100%\" style=\"position:absolute;left:0px;top:0px\">\n"+
		"<tr><td bgcolor=\"#CD3027\">\n"+
		"<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"100%\">\n "+
		"<tr>\n	<td bgcolor=\"#CD3027\"><a href=\"java script:parent.show_calendar2('"+str_target+"','"+ dt2dtstr(dt_prev_month)+"');\">"+
		"<img src=\""+web_root+"common/datepick/arwprev.gif\" width=\"16\" height=\"16\" border=\"0\""+
		" alt=\"previous month\"></a></td>\n"+
		"	<td bgcolor=\"#CD3027\" colspan=\"5\">"+
		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"
		+arr_months[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear()+"</font></td>\n "+
		"	<td bgcolor=\"#CD3027\" align=\"right\"><a href=\"java script:parent.show_calendar2('"+str_target+"','"+dt2dtstr(dt_next_month)+"');\">"+
		"<img src=\""+web_root+"common/datepick/arwnext.gif\" width=\"16\" height=\"16\" border=\"0\""+
		" alt=\"next month\"></a></td>\n</tr>\n"
	);

	var dt_current_day = new Date(dt_firstday);
	// print weekdays titles
	str_buffer += "<tr>\n";
	for (var n=0; n<7; n++)
		str_buffer += "	<td bgcolor=\"#E3B0AC\">"+
		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"+
		week_days[(n_weekstart+n)%7]+"</font></td>\n";
	// print calendar table
	str_buffer += "</tr>\n";
	while (dt_current_day.getMonth() == dt_datetime.getMonth() || dt_current_day.getMonth() == dt_firstday.getMonth()) {
		// print row heder
		str_buffer += "<tr>\n";
		for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
				if (dt_current_day.getDate() == dt_datetime.getDate() && dt_current_day.getMonth() == dt_datetime.getMonth())
					// print current date
					str_buffer += "	<td bgcolor=\"#FFE88C\" align=\"right\">";
				else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
					// weekend days
					str_buffer += "	<td bgcolor=\"#F8D9D7\" align=\"right\">";
				else
					// print working days of current month
					str_buffer += "	<td bgcolor=\"white\" align=\"right\">";

				if (dt_current_day.getMonth() == dt_datetime.getMonth())
					// print days of current month
					str_buffer += "<a href=\"java script:parent.document.getElementById('"+str_target+
					"').value='"+dt2dtstr(dt_current_day)+"'; parent.hide_calendar();\" style=\"text-decoration:none\">"+
					"<font color=\"black\" face=\"tahoma, verdana\" size=\"2\">";
				else 
					// print days of other months
					str_buffer += "<a href=\"java script:parent.document.getElementById('"+str_target+
					"').value='"+dt2dtstr(dt_current_day)+"'; parent.hide_calendar();\" style=\"text-decoration:none\">"+
					"<font color=\"gray\" face=\"tahoma, verdana\" size=\"2\">";
				str_buffer += dt_current_day.getDate()+"</font></a></td>\n";
				dt_current_day.setDate(dt_current_day.getDate()+1);
		}
		// print row footer
		str_buffer += "</tr>\n";
	}
	// print calendar footer
	

	return str_buffer;
}

function load_calendar1(str_target, str_datetime) {
	var arr_months = ["January", "February", "March", "April", "May", "June",
		"July", "August", "September", "October", "November", "December"];
	var week_days = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
	var n_weekstart = 1; // day week starts from (normally 0 or 1)

	var dt_datetime = (str_datetime == null || str_datetime =="" || str_datetime =="0000-00-00" ?  new Date() : str2dt(str_datetime));

	var dt_prev_month = new Date(dt_datetime);
	dt_prev_month.setMonth(dt_datetime.getMonth()-1);

	var dt_next_month = new Date(dt_datetime);
	dt_next_month.setMonth(dt_datetime.getMonth()+1);
	var dt_firstday = new Date(dt_datetime);
	dt_firstday.setDate(1);

	dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);
	var dt_lastday = new Date(dt_next_month);
	dt_lastday.setDate(0);
	

	// html generation (feel free to tune it for your particular application)
	// print calendar header
	var str_buffer = new String (
		"<html>\n"+
		"<head><title>Calendar</title></head>\n"+
		"<body style=\"background-color:transparent\">\n"+
		"<table class=\"clsOTable\" cellspacing=\"0\" cellspadding=\"0\" border=\"0\" width=\"100%\" style=\"position:absolute;left:0px;top:0px\">\n"+
		"<tr><td bgcolor=\"#CD3027\">\n"+
		"<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"100%\">\n "+
		"<tr>\n	<td bgcolor=\"#CD3027\"><a href=\"java script:parent.show_calendar2('"+str_target+"','"+ dt2dtstr(dt_prev_month)+"');\">"+
		"<img src=\""+web_root+"common/datepick/arwprev.gif\" width=\"16\" height=\"16\" border=\"0\""+
		" alt=\"previous month\"></a></td>\n"+
		"	<td bgcolor=\"#CD3027\" colspan=\"5\">"+
		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"
		+arr_months[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear()+"</font></td>\n "+
		"	<td bgcolor=\"#CD3027\" align=\"right\"><a href=\"java script:parent.show_calendar2('"+str_target+"','"+dt2dtstr(dt_next_month)+"');\">"+
		"<img src=\""+web_root+"common/datepick/arwnext.gif\" width=\"16\" height=\"16\" border=\"0\""+
		" alt=\"next month\"></a></td>\n</tr>\n"
	);

	var dt_current_day = new Date(dt_firstday);
	// print weekdays titles
	str_buffer += "<tr>\n";
	for (var n=0; n<7; n++)
		str_buffer += "	<td bgcolor=\"#E3B0AC\">"+
		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"+
		week_days[(n_weekstart+n)%7]+"</font></td>\n";
	// print calendar table
	str_buffer += "</tr>\n";
	while (dt_current_day.getMonth() == dt_datetime.getMonth() || dt_current_day.getMonth() == dt_firstday.getMonth()) {
		// print row heder
		str_buffer += "<tr>\n";
		for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
				if (dt_current_day.getDate() == dt_datetime.getDate() && dt_current_day.getMonth() == dt_datetime.getMonth())
					// print current date
					str_buffer += "	<td bgcolor=\"#FFE88C\" align=\"right\">";
				else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
					// weekend days
					str_buffer += "	<td bgcolor=\"#F8D9D7\" align=\"right\">";
				else
					// print working days of current month
					str_buffer += "	<td bgcolor=\"white\" align=\"right\">";

				if (dt_current_day.getMonth() == dt_datetime.getMonth())
					// print days of current month
					str_buffer += "<a href=\"java script:parent.document.getElementById('"+str_target+
					"').value='"+dt2dtstr(dt_current_day)+"'; parent.hide_calendar();\" style=\"text-decoration:none\">"+
					"<font color=\"black\" face=\"tahoma, verdana\" size=\"2\">";
				else 
					// print days of other months
					str_buffer += "<a href=\"java script:parent.document.getElementById('"+str_target+
					"').value='"+dt2dtstr(dt_current_day)+"'; parent.hide_calendar();\" style=\"text-decoration:none\">"+
					"<font color=\"gray\" face=\"tahoma, verdana\" size=\"2\">";
				str_buffer += dt_current_day.getDate()+"</font></a></td>\n";
				dt_current_day.setDate(dt_current_day.getDate()+1);
		}
		// print row footer
		str_buffer += "</tr>\n";
	}
	// print calendar footer
	

	return str_buffer;
}

function show_calendar(str_target,str_datetime){
	var str=load_calendar(str_target,str_datetime);
	var iCaldoc = iCal.document;
	iCaldoc.write(str);
	iCaldoc.close();


	el = document.getElementById(str_target);

	xPos = el.offsetLeft;
	tempEl = el.offsetParent;
	while (tempEl != null) {
		xPos += tempEl.offsetLeft;
		tempEl = tempEl.offsetParent;
	}

	yPos = el.offsetTop;
	tempEl = el.offsetParent;
	while (tempEl != null) {
		yPos += tempEl.offsetTop;
		tempEl = tempEl.offsetParent;
	}
	
	if (document.getElementById('iCal').style.left=="-500px"){
		document.getElementById('iCal').style.top = yPos + el.offsetHeight + 2;
		document.getElementById('iCal').style.left = xPos;
	} else {
		hide_calendar();
	}
}

function show_calendar2(str_target,str_datetime){
	var str=load_calendar1(str_target,str_datetime);
	var iCaldoc = iCal.document;
	iCaldoc.write(str);
	iCaldoc.close();


	el = document.getElementById(str_target);

	xPos = el.offsetLeft;
	tempEl = el.offsetParent;
	while (tempEl != null) {
		xPos += tempEl.offsetLeft;
		tempEl = tempEl.offsetParent;
	}

	yPos = el.offsetTop;
	tempEl = el.offsetParent;
	while (tempEl != null) {
		yPos += tempEl.offsetTop;
		tempEl = tempEl.offsetParent;
	}
	
	document.getElementById('iCal').style.top = yPos + el.offsetHeight + 2;
	document.getElementById('iCal').style.left = xPos;
}

function hide_calendar(){

	document.getElementById('iCal').style.left=-500
}

// datetime parsing and formatting routimes. modify them if you wish other datetime format
/*function str2dt (str_datetime) {
	var re_date = /^(\d\d\d\d)\-(\d\d)\-(\d\d)$/;
	if (!re_date.exec(str_datetime))
		return alert("Invalid Datetime format: "+ str_datetime);
	return (new Date (RegExp.$1, RegExp.$2-1, RegExp.$3));
}*/

function str2dt (str_datetime) {
	var re_date = /^(\d\d\d\d)\-(\d\d)\-(\d\d)$/;
	if(!re_date.exec(str_datetime))
	{
		re_date = /^(\d\d)\/(\d\d)\/(\d\d\d\d)$/;
		if(!re_date.exec(str_datetime))
		{
			return alert("Invalid Datetime format: "+ str_datetime);
		}else
		{
			type_cal=2;	
		}
	}else
	{
		type_cal=1;	
	}
	if(type_cal==1)
	{
		return (new Date (RegExp.$1, RegExp.$2-1, RegExp.$3));
	}else if(type_cal==2)
	{
		return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1));
	}
	
}

function dt2dtstr (dt_datetime) {
	if(type_cal==1)
	{
		return (new String (
			dt_datetime.getFullYear()+"-"+pd02((dt_datetime.getMonth()+1))+"-"+pd02(dt_datetime.getDate())));
	}else if(type_cal==2)
	{
		return (new String (
			pd02(dt_datetime.getDate())+"/"+pd02((dt_datetime.getMonth()+1))+"/"+dt_datetime.getFullYear()));
	}
}
function dt2tmstr (dt_datetime) {
	return (new String (
			dt_datetime.getHours()+":"+dt_datetime.getMinutes()+":"+dt_datetime.getSeconds()));
}

function pd02(number){
	number = ""+number;

	if (number.length==0)
		return "00";
	else if (number.length==1)
		return "0" + number;
	else
		return number;
}








Thank you very much for your help,


BamBam

Is This A Good Question/Topic? 0
  • +

Replies To: Javascript datepicker date

#2 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 674
  • View blog
  • Posts: 4,349
  • Joined: 24-October 08

Re: Javascript datepicker date

Posted 11 October 2009 - 01:51 PM

sorry this is the Java forum and not the javascript one, no worries though, a mod will move this to the right place soon enough and you'll be getting help :)
Was This Post Helpful? 0
  • +
  • -

#3 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 3873
  • View blog
  • Posts: 11,407
  • Joined: 18-April 07

Re: Javascript datepicker date

Posted 11 October 2009 - 02:53 PM

Hello bambinou,

What they meant by the statement at the end is if you wanted a format other than the two they have specified...YYYY-MM-DD or DD/MM/YYYY. Since you want the latter, no need to modify anything. When you make calls to load_calendar, to load the calendar, pass it a date in the DD/MM/YYYY format and the calendar SHOULD display the dates in the same format. My guess is that you are giving it either no date, which then defaults to the american style or you are giving it the american style when you call load_calendar().

If you are not supplying it a date when you call load_calendar(), and only giving it the target, then you can modify the if, elseif and else like so...

if(str_datetime =="0000-00-00")
{
	 dd=get_date.getDate();
	 dd=get2DigitDate(dd);
	 mm=get_date.getMonth()+1;
	 mm=get2DigitMonth(mm);
	 yy=get_date.getFullYear();
	 // Notice here the new style
	 str_datetime=dd+'-'+mm+'-'+yy;
}else if(str_datetime =="0000/00/00")
{
	 dd=get_date.getDate();
	 dd=get2DigitDate(dd);
	 mm=get_date.getMonth()+1;
	 mm=get2DigitMonth(mm);
	 yy=get_date.getFullYear();
	 // Again, new style
	 str_datetime=dd+'/'+mm+'/'+yy;
}else
{
	 dd=get_date.getDate();
	 dd=get2DigitDate(dd);
	 mm=get_date.getMonth()+1;
	 mm=get2DigitMonth(mm);
	 yy=get_date.getFullYear();
	 // Again new style
	 str_datetime=dd+'-'+mm+'-'+yy;
}



What these changes above are going to do is format the dates into the appropriate DD/MM/YYYY or DD-MM-YYYY styles if you are not passing a date value to load_calendar(). Otherwise, just make sure you pass a date to load_calendar() in the format DD/MM/YYYY and it will spit back values of DD/MM/YYYY automatically.

:)
Was This Post Helpful? 0
  • +
  • -

#4 bambinou  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 11-October 09

Re: Javascript datepicker date

Posted 11 October 2009 - 03:44 PM

Hi Martyr,

Thank you so much for your help, as I said I am quiet new to this, I am trying to find the load calender code on my page,,,,I will keep you informed.

Thank!


Ben
Was This Post Helpful? 0
  • +
  • -

#5 bambinou  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 11-October 09

Re: Javascript datepicker date

Posted 11 October 2009 - 03:57 PM

Ok so, I have been on the form itself and foundt his code, I think you are right ,something else is modifying the way the date is passing but I cannot find the onload even you were speaking about, any idea what I should change on this page please? I understand the first line,months...but then I can quiet lost.


	
<select name="selmonth">
	<?
	$months = array("January","February","March","April","May","June","July","August","September","October","November","December");
	for ($i = 0; $i < 12; $i++){
		$m = $i+1;
		if($do != "view"){
			echo "<option value=\"$m\" ".($m == date("m")?"selected":"").">$months[$i]</option>";
		}else{
			echo "<option value=\"$m\" ".($m == $selmonth?"selected":"").">$months[$i]</option>";
		}
	} 
	?>		
	</select>
	
	<span style="margin-left:2px"><?=$lang['eagent']['year']?> 
	
	<select name="selyear">
	<?
	  for ($i=date("Y"); $i>=2008; $i--){
		if($do != "view"){
			echo "<option value=\"$i\" ".($i == date("Y")?"selected":"").">$i</option>";
		}else{
			echo "<option value=\"$i\" ".($i == $selyear?"selected":"").">$i</option>";
		}
	  } 
	?>	
	</select> 
		<input type="submit" value=" <?=$lang['eagent']['go']?> ">
	</td></tr>	
	<?php 
		if($month == $viewmonth && $year == $viewyear){
			echo "<tr><td height=\"30\">".$lang['eagent']['viewingrecord']."<td/><td>".format_date($viewyear."-".$viewmonth."-02")." ".$lang['eagent']['to']." ".format_date($currentdate)."</td></tr>";
		}else{	
			echo "<tr><td height=\"30\">".$lang['eagent']['viewingrecord']."<td/><td>".$months[$vm-1]." ".$viewyear."</td></tr>";	
		}



Was This Post Helpful? 0
  • +
  • -

#6 bambinou  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 11-October 09

Re: Javascript datepicker date

Posted 11 October 2009 - 04:16 PM

View Postbambinou, on 11 Oct, 2009 - 02:57 PM, said:

Ok so, I have been on the form where the calendar comes from, and found this code, I think you are right ,something else is modifying the way the date is passing but I cannot find the onload even you were speaking about, any idea what I should change on this page please? I understand the first line,months...but then I can quiet lost.


	
<select name="selmonth">
	<?
	$months = array("January","February","March","April","May","June","July","August","September","October","November","December");
	for ($i = 0; $i < 12; $i++){
		$m = $i+1;
		if($do != "view"){
			echo "<option value=\"$m\" ".($m == date("m")?"selected":"").">$months[$i]</option>";
		}else{
			echo "<option value=\"$m\" ".($m == $selmonth?"selected":"").">$months[$i]</option>";
		}
	} 
	?>		
	</select>
	
	<span style="margin-left:2px"><?=$lang['eagent']['year']?> 
	
	<select name="selyear">
	<?
	  for ($i=date("Y"); $i>=2008; $i--){
		if($do != "view"){
			echo "<option value=\"$i\" ".($i == date("Y")?"selected":"").">$i</option>";
		}else{
			echo "<option value=\"$i\" ".($i == $selyear?"selected":"").">$i</option>";
		}
	  } 
	?>	
	</select> 
		<input type="submit" value=" <?=$lang['eagent']['go']?> ">
	</td></tr>	
	<?php 
		if($month == $viewmonth && $year == $viewyear){
			echo "<tr><td height=\"30\">".$lang['eagent']['viewingrecord']."<td/><td>".format_date($viewyear."-".$viewmonth."-02")." ".$lang['eagent']['to']." ".format_date($currentdate)."</td></tr>";
		}else{	
			echo "<tr><td height=\"30\">".$lang['eagent']['viewingrecord']."<td/><td>".$months[$vm-1]." ".$viewyear."</td></tr>";	
		}





I have just tried your new code , did I do it right? I have copied all your code below this line:
// datetime parsing and formatting routimes. modify them if you wish other datetime format
/*function str2dt (str_datetime) {
var re_date = /^(\d\d\d\d)\-(\d\d)\-(\d\d)$/;
if (!re_date.exec(str_datetime))
return alert("Invalid Datetime format: "+ str_datetime);
return (new Date (RegExp.$1, RegExp.$2-1, RegExp.$3));
}*/


Thanks!,


If I did it right then the code does not work.


BamBam
Was This Post Helpful? 0
  • +
  • -

#7 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 3873
  • View blog
  • Posts: 11,407
  • Joined: 18-April 07

Re: Javascript datepicker date

Posted 11 October 2009 - 04:25 PM

The code I provided was for the load_calendar() method. And like I said, the changes I made to that code was for the instance that NO date was being passed in. Look in your code somewhere until you see some javascript that reads "show_calendar(blah,blah)" where of course blah blah is the two parameters being passed in. This method in turn calls load_calendar(). So I need to see what your code is giving show_calendar() so I know how load_calendar is behaving.

Show us the part of your form that has show_calendar() being used in it. Thanks! :)
Was This Post Helpful? 0
  • +
  • -

#8 bambinou  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 11-October 09

Re: Javascript datepicker date

Posted 11 October 2009 - 05:29 PM

Thanks Martyr for your help,


If you don't mind I will come back and write my findings in the forum later on today, it is 2.30am here, I can't even keep my eyes open :-)

Thanks again for your great help, speak to you soon,


BamBam
Was This Post Helpful? 0
  • +
  • -

#9 bambinou  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 11-October 09

Re: Javascript datepicker date

Posted 12 October 2009 - 01:53 AM

Hi Matyr,


I went back on it this morning and found this:
<input type="text" name="dailysalesdate" id="dailysalesdate" value="<?=$dailysalesdate?>"> 
		  <a href="java script:show_calendar('dailysalesdate', document.searchform.dailysalesdate.value, '<?=$path["webroot"]?>');">



Now for the dailysalesdate, at the top of the form there is this:

if (empty($dailysalesdate))  { $dailysalesdate = $currentdate;}


So, I am trying to understand the show_calendar event, it says ,the document value of the search form "dailysalesdate"


could this be the line we are looking after?

if($month == $viewmonth && $year == $viewyear){
			echo "<tr><td height=\"30\">".$lang['eagent']['viewingrecord']."<td/><td>".format_date($viewyear."-".$viewmonth."-02")." ".$lang['eagent']['to']." ".format_date($currentdate)."</td></tr>";
		}else{	
			echo "<tr><td height=\"30\">".$lang['eagent']['viewingrecord']."<td/><td>".$months[$vm-1]." ".$viewyear."</td></tr>";	

Was This Post Helpful? 0
  • +
  • -

#10 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 3873
  • View blog
  • Posts: 11,407
  • Joined: 18-April 07

Re: Javascript datepicker date

Posted 12 October 2009 - 09:30 AM

Actually it says that we are getting the value to pass to show_calendar from a web form control called "dailysalesdate" which is in the form "searchform" in the current document. So the thing we have find next is the textbox, drop down, or whatever control that has the name "dailysalesdate" THAT control is determining your calendar format. The format of the date there is the date going into show_calendar which passes it to load_calendar and outputs the format.

The more I look at this the more appears this javascript has a few issues. If you still have problems, perhaps you can package up the javascript file and the html that has the form on it into a package and add it to your post. That way I can see everything.

Thanks.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1