I don't know much js, but where is the submit/save button/function?

sexta-feira, 26 de Abril de 2019 às 11:19:19 UTC+1, Andrea Fae' escreveu:
>
> Thank you for your answer, but I do not understand the code you wrote...
> the 2 fields are only filtering fields, no a db field.
>
> The filtering fields are working well, but I want that the dates selected 
> will be preserved after postback. Do I have to read them from the 
> querystring? In which way?
>
>
> This is my code
>
> <script>
>     var srchI, srchF, srch;
>     
>     // funzione che consente di impostare la ricerca Dalla Data
>     function datainizioSrch(){
>         var dataDa = 
> moment($('#datepickerI').datepicker("getDate")).format('YYYY-MM-DD');
>         srchI ='evento.inizio >= ' + '"' + dataDa + '"';
>         if (srchF != undefined) {
>            srch = srchI + ' and ' + srchF;
>         } else {
>             srch = srchI;
>         }
>         // console.log(srch);
>         $("#w2p_keywords").val(srch);
>     }
>     // funzione che consente di impostare la ricerca Alla Data
>     function datafineSrch(){
>         // aggiunge 1 giorno per includere anche l'ultimo giorno della 
> data di ricerca dataA
>         var dataA = moment($('#datepickerF').datepicker("getDate")).add(1, 
> 'days').format('YYYY-MM-DD');
>         srchF ='evento.fine <= ' + '"' + dataA + '"';
>         if (srchI != undefined) {
>            srch = srchI + ' and ' + srchF;
>         } else {
>             srch = srchF;
>         }
>         // console.log(srch);
>         $("#w2p_keywords").val(srch);
>     }
>
>     $(document).ready(function(){
>
>         // la funzione di ricerca standard della grid viene nascosta  
>         $("#w2p_keywords").prop("type", "hidden");
>
>         // Inserire gli elementi della ricerca custom dopo la ricerca 
> standard ("#w2p_keywords").
>         // Questo consente di non farla vedere sulle pagine edit e view
>         // inserire i campi di ricerca nell'ordine inverso con i quali 
> appaiono nella pagina
>         
>         var inputStr  = '<form class="form-inline"> <div 
> class="form-group" style="padding-bottom:5px;">Dalla Data: <input 
> type="text" id="datepickerI" class="datepicker" readonly="true" 
> onchange="datainizioSrch()"></div> <div class="form-group" 
> style="padding-bottom:5px;">Alla Data: <input type="text" id="datepickerF" 
> class="datepicker" readonly="true" onchange="datafineSrch()"></div></form>';
>         $(inputStr).insertAfter("#w2p_keywords");
>         
>         // definisco il datepicker
>         $("#datepickerI").datepicker({
>             dateFormat: "dd/mm/yy",
>             autoSize: true,
>             firstDay: 1,
>             dayNamesMin: ["Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa"],
>             monthNames: [ "Gennaio", "Febbraio", "Marzo", "Aprile", 
> "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", 
> "Dicembre" ],
>         });
>         $("#datepickerF").datepicker({
>             dateFormat: "dd/mm/yy",
>             autoSize: true,
>             firstDay: 1,
>             dayNamesMin: ["Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa"],
>             monthNames: [ "Gennaio", "Febbraio", "Marzo", "Aprile", 
> "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", 
> "Dicembre" ],
>         });
>     });
> </script>
> thank you
>
> Il giorno venerdì 26 aprile 2019 00:04:39 UTC+2, João Matos ha scritto:
>>
>> Is the selected date in a db field? Then when editing the same field, the 
>> date picker should show the selected date.
>>
>> If the date is still not saved to a db field but only in js, then you can 
>> send it using something similar to this
>>
>>         <script type = "text/javascript">
>>             <!--
>>                 do {
>>                     var correctValues = ["1", "2", "3", ""];
>>                     var retVal = prompt("{{=T('Starting position')}} (1, 
>> 2, 3): ", "1");
>>                 } while (!(retVal in correctValues) & retVal !== null);
>>
>>                 if (retVal === null) {
>>                     window.location.href = 
>> "{{=request.env.http_referer}}";
>>                 } else {
>>                     window.location.href = "{{
>>                         url = 'https://' if request.is_https else 
>> 'http://'
>>                         url += request.env.http_host + request.url + '/'
>>                         =url
>>                     }}" + retVal + "?{{=request.env.query_string}}";
>>                 }
>>              //-->
>>         </script>
>>
>>
>>
>> quinta-feira, 25 de Abril de 2019 às 20:40:25 UTC+1, Andrea Fae' escreveu:
>>>
>>> How to preserve datepicker selected date after postback using web2py in 
>>> a javascript view... I think it's a javascript problem but I don't know how 
>>> to fix it.
>>> thank you
>>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to