Add datetime picker in custom file

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
christ2000
User
Posts: 519

Add datetime picker in custom file

Post by christ2000 »

hello i am using the code bellow to show a datetimepicker in a custom file, the field show properly but i cant remove the time on the field, because i just need date, i think there is a script on the code that must be place in other place, but i could find in custom file otionp

is there any way to reach this, or show a picker in other way?

thanks


christ2000
User
Posts: 519

Post by christ2000 »

the script code is:

<sc ript>
$(function () {
$('#datetimepicker4').datetimepicker({
format: 'L'
});
});
</script>



christ2000
User
Posts: 519

Post by christ2000 »

hello is this way correct?

<scr ipt>
loadjs.ready("load", function() {
$('#datetimepicker4').datetimepicker({
format: 'L'
});
});

</scri pt>

thanks for help


mobhar
User
Posts: 11745

Post by mobhar »

Try this (make sure you have replaced "your_form_id" with your actual form id, and assume the "datetimepicker4" is the id of the related textbox control):

<scr ipt>
loadjs.ready(["your_form_id", "datetimepicker"], function() {
ew.createDateTimePicker("your_form_id", "datetimepicker4", {"ignoreReadonly":true,"useCurrent":false,"format":1});
});
</scr ipt>


christ2000
User
Posts: 519

Post by christ2000 »

Hello mohar i test your code but dosent work, what i need is to remove the time from the textbox control and just show date. now i dont have a form just a textbox for testing in a custom file

i put on my in head your code on this way:

<sc ript>
loadjs.ready(["datetimepicker4", "datetimepicker"], function() {
ew.createDateTimePicker("datetimepicker4", "datetimepicker4", {"ignoreReadonly":true,"useCurrent":false,"format":1});
});
</scri pt>

and in my custom file this code:

            <di v class="in put-group date" id="datetimepicker4" data-target-input="nearest">
                <inp ut type="text" class="form-control datetimepicker-input" data-target="#datetimepicker4"/>
                <di v class="inp ut-group-append" data-target="#datetimepicker4" data-toggle="datetimepicker">
                    <di v class="inp ut-group-text"><i class="fa fa-calendar"></i></div>

but the time still appear on textbox when i select date

any idea?


mobhar
User
Posts: 11745

Post by mobhar »

Try to play with the "format" option in this code:
ew.createDateTimePicker("datetimepicker4", "datetimepicker4", {"ignoreReadonly":true,"useCurrent":false,"format":1});

For example, change it to 2 (Short Date - without time) instead of 1 (Long Date - with time). You may read for further more from the generated phpfn.php file; see the comment/explanation above the FormatDateTime() global function.

Just put that code below the code that displaying Textbox control. You may actually refer to the generated code in a Add/Edit page that implements datetimepicker.


christ2000
User
Posts: 519

Post by christ2000 »

hello, i did but dosent work, but also i copied the exact code from a generate page where i use a datetimepicker, and in a custom filethe code show TIME and on the original page not, so i think in a custom file always will show the time

<in put type="text" data-table="ratesupdates" data-field="x_newratedate" data-format="2" name="x_newratedate" id="x_newratedate" placeholder="" value="" class="form-control datetimepicker-input" data-target="#datetimepicker_fratesupdatesaddx_newratedate">


mobhar
User
Posts: 11745

Post by mobhar »

Where is the code to display the datetimepicker control?


christ2000
User
Posts: 519

Post by christ2000 »

="ct_ratesupdates_add">Rate Start On&nb p;<sp an id ="el_ratesupdates_newratedate">
<d iv clas s="in put-grou p date" id="dateti me picker_fratesupdat esaddx_newratedate" da ta-targ et-in p ut="nearest"><inp ut ty pe="text" d ata-tab le="ratesupdates" da ta-field="x_newratedate" da ta-for ma t="2" name="x_newratedate" id="x_newratedate" place holder="" v alue="" class="form-control dateti mepicker-input" data-targ et="#datetimepicker_fratesupdatesaddx_newratedate"><di v clas s="in put-gro up-app end" data-ta rget="#datetimepicker_fratesupdatesaddx_newratedate" data-tog gle="datetim epicker"><butt o n clas s="btn btn-default" type="but ton"><i cl ass="far fa-calendar-alt"></i></but ton></ iv>


mobhar
User
Posts: 11745

Post by mobhar »

I did not see ew.createDateTimePicker in your code.


christ2000
User
Posts: 519

Post by christ2000 »

i yhis way code is show in generate file, any way i will forget this

thanks


Post Reply