Date Picker help

meanster99

Well-known member
Hi again!

Using DaDaBIK v4.3. Trying to get the datepicker working, used by JP here: http://www.dadabik.org/forum/read.php?1,10318,10796#msg-10796 (http://www.rainforestnet.com/datetimepicker.htm).

Have added the reference to my header.php:
<script language="javascript" type="text/javascript" src="../js/datetimepicker_css.js"></script>

Have modified include/internal_table.php by adding:
pick_date to the list in $int_fields_ar[2][3] =

Also added to include/business_logic.php (including mod to have datepicker on search form):
[pre]
case "pick_date":
$form .= "<td class=\"td_input_form\">".$select_type_select."<input type=\"text\" name=\"".$field_name_temp."\"";
if ($fields_labels_ar[$i]["width_field"] != ""){
$form .= " size=\"".$fields_labels_ar[$i]["width_field"]."\"";
} // end if
$form .= " id=\"".$field_name_temp."\""; // needed for Rainforest Javascript Date Time Picker
$form .= " maxlength=\"".$fields_labels_ar[$i]["maxlength_field"]."\"";
if ($form_type == "update" or $form_type == "ext_update"){
if ($show_edit_form_after_error === 1){
if (isset($_POST[$field_name_temp])) {
$form .= " value=\"".htmlspecialchars(stripslashes($_POST[$field_name_temp]))."\"";
} // end if
} // end if
else {
$form .= " value=\"".htmlspecialchars($details_row[$field_name_temp])."\"";
} // end else
} // end if
if ($form_type == "insert"){
if ($show_insert_form_after_error === 1 && isset($_POST[$field_name_temp])) {
$form .= ' value="'.htmlspecialchars(stripslashes($_POST[$field_name_temp])).'"';
} // end if
else {
$form .= " value=\"".$fields_labels_ar[$i]["prefix_field"].$fields_labels_ar[$i]["default_value_field"]."\"";
} // end else
} // end if
$form .= ">";
if ($form_type == "update" or $form_type == "insert" or $form_type == "search"){
$form .= " <a href=\"javascript:NewCssCal('".$field_name_temp."','ddMMyyyy','arrow')\"><img src=\"./images/cal.gif\" class=\"form_calendar\" alt=\"Calendar\"></a>";
} // end if
$form .= "</td>"; // add the second coloumn to the form
break;
[/pre]
(by the way, it's slightly confusing for complete noobs like me when quoted code doesn't display correctly in browsers and adds smileys or input boxes, as in JP's post and in my quote above! Took me a while to realise the smiley was ONLY a close bracket and not a semi-colon and close bracket! Also, the 2 blocks of code quoted by JP in the referenced post appear to be slightly different, excluding the adding of datepicker to search forms - so hope I have the right code).

Have also implemented the change below from post Want to set up a datepicker
nmcgann said:
Function get_field_correct_displaying in business_logic.php needs pick_date adding as a case so that the dates show in the normal date field format in table displays (e.g. "13 Nov 2010". )

look for this and stick the pick_date case in:
case "insert_date":
case "update_date":
case "date":
case "pick_date":

I have also added the following class to styles_screen.css (again taken from a post by JP) to help position the calendar icon more appropriately:
.form_calendar {
vertical-align: bottom;
margin-bottom: 4px;
padding: 0px;
width: 19px;
height: 16px;
border: 0px;
}

I only have one date field in one table of my DB (mySQL) which looks to be stored in the format "yyyy-mm-dd".

The default datepicker icon (./images/cal.gif) appears by my date field in my add new, edit and search forms but when clicked on NOTHING happens - I have checked the element using firebug and it appears to reference the javascript OK but is obviously not working for some reason. I'm thinking maybe I've got a path wrong somewhere, because I have put the javascript file in its own folder (js) in the root directory of my dadabik installation. I have tried all the various date formats (yyyyMMdd, ddmmyyyy etc etc) in the line from case "pick_date": in the business_logic.php, but that makes no difference.

Anyone have any suggestions or can see where I may have gone wrong?
 

meanster99

Well-known member
Ok have worked it out - it was just an incorrect reference. I moved the javascript file to the 'include' folder and now the datepicker pops up when the button is clicked. Just need to get the date formats right now (consistent between dadabik, mysql and the html form I use to capture other info). Shouldn't be that hard though, I hope...
 

JP

Member
Glad you got it worked out, also glad to see it still works in a newer release of dadabik :)
 
Top