How to pass the jquery datepicker value in form POST method?

后端 未结 3 1215
我在风中等你
我在风中等你 2021-01-12 03:08

I have a input text in the form for date and i use JQuery datepicker to select date.

 

        
3条回答
  •  南方客
    南方客 (楼主)
    2021-01-12 03:51

    $( "#currentDate" ).datepicker("setDate", new Date(""));
    

    works for me, read at least 10 very complicated ways of doing it and then realised this works. You are instantiating a new value each time. you store the date somewhere in your php scripts, using form input or some other technique and then recycle it back into the above statement. So reloading doesn't affect the result.

    If myCurrentDate is unset it will set it by default. Getting it to be set to today's date requires a php if statement to set it the first time (or reload the page) to new Date() and the else statement can be used to include the above code.

提交回复
热议问题