javascript - How can I pass PHP variable to Datepicker in jQuery? -


I am trying to set the default date in datepicker with a variable that I pass through PHP in html. Here is a simplified version of both my control file and the form:

Control file:

  & lt ;? Php function render ($ template, $ value = []) / / Remove the variable in the local charge removal ($ value); // render template is required ("$ template"); } $ Default_date = date ("m / d / y"); $ Default_date = strtotime ($ default_date); $ Default_date = $ default_date + 604800; $ Default_date = Date ("Y, M-1, D", $ default_date); Render ("index_month2_form.php", ['default_date' = & gt; $ default_date]); ? & Gt;   

And this is the form:

   Doctype html & gt; & Lt; Html lang = "en" & gt; & Lt; Top & gt; & Lt ;? Php print "$ default_date"; ? & Gt; & Lt; Meta charset = "UTF-8" & gt; & Lt; Title & gt; JQuery UI Datepicker - default functionality & lt; / Title & gt; & Lt; Link rel = "stylesheet" href = "jqueryui / css / swanky-purse / jquery-ui-1.10.4.custom.css" & gt; & Lt; Script src = "/ jqueryui / jquery-1.11.1.min.js" & gt; & Lt; / Script & gt; & Lt; Script src = "jqueryui / js / jquery-ui-1.10.4.custom.min.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; $ (Function () {$ ("(mydate"). } / Datecker (fixed date, new date ()); .date picture ("setdate", new date (2014,10-1,17))); & lt; / script & gt; & lt; / Head> gt; & gt; & gt; & lt; p & gt; Date: & lt; input type = "text" id = "mydate" & gt; & lt; / p & gt; & lt; / body >     

If I use the commented line for the set date, then I get the current date, if I use the line I will get 7 days ahead date. When I print the $ default_date I print the 2014, 10-1.17 at the top of the form, but I can not get out of the way to pass it in the script. Others have suggested that

is the way to use echo. Script instead of input - I think $ default_date === "2014,10-1,17"

  $ (function () {$ ("#mindet"). Date (Date: Text, Inst.) {Var dateAsString = dateText; var date = $ ('# mydate'). Val ();}}) //.datepicker ("setset", new date) ); .data ("Setdate", New Date (& lt ;? Php $ date = Explosion (',', $ default_date); $ date echo [0]. ','. $ Date [1] ','. $ $ [2];; & gt;));}; Edit: 
As seen in RSS 81, the string has been badly damaged due to the reconstruction of the same string.I do not know what I am thinking ... Yet I would prefer it for educational purposes.

The string explosion enables us to get the strings of each category individually by comma, you can use it to rearrange the string, for example if you "2014,10-1 , 17 "to" 10- 1,2014,17 "which will be done by AllO $ date [1]. ',' $ Date [0]. ','. $ Date [2]

Echo enables us to output HTML pages as we make it dynamic. So here we are pre-processing logic of .datepicker () by php .

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -