close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Date Picker CSS Form Builder Inserts 0000-00-00 00:00:00

Thread began 1/31/2010 4:39 pm by dlovas275157 | Last modified 1/10/2012 11:33 am by afeliksas433126 | 9134 views | 10 replies |

dlovas275157

Date Picker CSS Form Builder Inserts 0000-00-00 00:00:00

I have implemented the Date Picker via the CSS Form Builder. The datepicker appears in the form as needed, however when the record is inserted into my database, the datetime field is "0000-00-00 00:00:00" instead of the proper date such as "2009-08-20 10:40:43".

Below are the steps I followed:
1. Create insert.php form via DataAssist Wizard.
2. Take insert.php form into CSS Form Builder and edit the form so dateCreated field has a datepicker instead of textfield. Apply CSS Design, and Finish wizard.
3. Edit Insert Record SB in the SB Panel so the form fields are binded to the values from the new recordset created by the CSS Form Builder wizard, instead of binded to the original recordset.
4. Test form. Inserting record fully works accept the dates as noted above.

My date fields in my database are formatted at datetime YYYY-MM-DD hh:mm:ss and must stay this way for other reasons. Example entry: 2009-08-31 11:54:00

Maybe this is related to validation?

Sign in to reply to this post

dlovas275157

Attached is insert.php file....

Thnx

Attached Files
bmg_artists_InsertDP.php.zip
Sign in to reply to this post

Eric Mittman

You may need to reformat the date value before it is inserted into the db. To do this you will need to make use of the date function in php.

The format for the date you would like to get would look like this:

php:
date("Y-m-d h:i:s", strtotime($_POST['dateCreated']));



If you need the time to be in 24 hour format you would use G instead of h in the date function. What this formatting is doing is taking the dateCreated and making it into a timestamp with the strtotime function. This timestamp is then formated with the string in the date function. You will want to do this to the value in the insert statement, so rather than just inserting the posted value you will insert this formatted version of the posted value.

Here is a link to the pages for these functions:

date
php.net/manual/en/function.date.php

strtotime
php.net/strtotime

Sign in to reply to this post

dlovas275157

Eric,

I appreciate the response, sorry for the late reply. Looking into the links you sent.

Does WA "client side validation" in the toolkit only deal with "date" and not "datetime"?

I tried also using "date" instead of "datetime" and using the WA Validation Toolkit see my post here at bottom of this thread:

showthread.php?t=3665&highlight=reformat+date

Date seems like an easier format to work with, but ran into validation issues?

Sign in to reply to this post

Eric Mittman

It looks like the client side validation is passing but your server side or spry validation is failing. Do you have server side validation applied to this form field? You should check the server validations that you have on this page and look for a date type or any other that is applied to this field. You may need to update it to allow for the reformatted date, or if you have too much trouble with it you might want to remove it to see what effect that has.

Sign in to reply to this post

dlovas275157

Eric,

Yes. Server-Side and Client-Side are applied to the date field. All date-types and format were set as supposed to according to WA documentation, but it still would not pass validation. Removing validation caused the date to insert as 0000-00-00 everytime obviously since the client validations which handled reformatting was removed.

It does not seem that the validation works as is it supposed to, or I cannot find clear WA documentation outside the forums to get it to work properly. Anyone else have this issue?

As a solution, I have followed this thread's instructions by Dani Chankhour:

showthread.php?t=9674

With this implementation, I was able to leave all validations in place (client and server side) that were created via CSS Form Builder and after when I added the client side js based validation.

I still have a lot of testing to do to make sure this method is fool-proof, but maybe this will help someone else.

Thanks for your help Eric/Dani. I appreciate it! -DL

Sign in to reply to this post

afeliksas433126

Datepicker does not pass date to database

Hi,

I'm trying to apply Datepicker to my User Registration Form. Inserted DatePicker into the "Date of Birth" field, applied date format 'yy-mm-dd' (the same as on database). Database field type is set "Date", the scrip is as follows:

$(function(){
$('#datepicker_1').datepicker({
dateFormat: 'yy-mm-dd',
showAnim: 'fade',
onClose: closeDatePicker_datepicker_1,
changeYear: true,
yearRange: '1850:+01'
});
});
function closeDatePicker_datepicker_1() {
var tElm = $('#datepicker_1');
if (typeof datepicker_1_Spry != null && typeof datepicker_1_Spry != "undefined") {
datepicker_1_Spry.validate();
}
var docElm = document.getElementById("datepicker_1");
var tBlur = docElm.getAttribute("onBlur");
if (!tBlur) tBlur = docElm.getAttribute("onblur");
if (!tBlur) tBlur = docElm.getAttribute("ONBLUR");
if (tBlur) {
tBlur = tBlur.replace(/\bthis\b/g, "docElm");
eval(tBlur);
}
}
----------------------------------------------------
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">GrBirthDate:</td>
<td><input id="datepicker_1" name="GrBirthDay" type="text" /></td>
</tr>

Can not get the date into the database, no value appears. Tried without Datepicker it works perfectly just I need to type in format 'yyyy-mm-dd'. Tried changing format to 'yyyy-mm-dd' for datepicker still no values go through to datase.

What am I doing wrong?

Sign in to reply to this post

Jason ByrnesWebAssist

the format of the date must be yyyy-mm-dd, you cannot use yy-mm-dd or any other format.

in some cases i have seen form elements with out a value attribute not work correctly, try changing:
<input id="datepicker_1" name="GrBirthDay" type="text" />

to:
<input id="datepicker_1" name="GrBirthDay" type="text" value="" />

if you are still having a problem after changing the format and adding the blank value, send a copy of your page in a zip archive so I can see the full code in context.

Sign in to reply to this post

afeliksas433126

Still problems with datepicker

Hi Jason,

Tried changing to 'yyyy-mm-dd' it brings another four characters of the year at the front.
Added blank value, didn't help still nothing goes through to database. The field below "GRDeathDate" which hasn't datepicker applied works well.

I've attached the zipped page

Attached Files
grave_list_Insertx.zip
Sign in to reply to this post

Jason ByrnesWebAssist

the insert record code is looking for a form element named "GrBirthDate" but there is not a form element with that name.

the date picker element is named "BirthdayPicker"


change:

php:
<td nowrap="nowrap" align="right">GrBirthDate:</td>

<td><input id="datepicker_1" name="BirthdayPicker" type="text" value=''/></td>



to:
change:

php:
<td nowrap="nowrap" align="right">GrBirthDate:</td>

<td><input id="datepicker_1" name="GrBirthDate" type="text" value=""/></td>
Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...