Note that there are some explanatory texts on larger screens.

plurals
  1. POGenerating a Javascript id in a loop
    primarykey
    data
    text
    <p>The following is code for a datepicker. When we select a date in from field, all the dates in "to" field which are below "from" field are blocked. I want to generate these ids with the help of for loop, but when I run this code the textbox only shows the datepicker with proper functionality of "from" and "to".</p> <pre><code>$(function () { var frm = 0; var tu = 0; var i = 0; for (i = 1; i &lt;= 5; i++) { frm = "#from" + i; tu = "#to" + i; $(frm).datepicker({ changeMonth: true, changeYear: true, dateFormat: 'yy/mm/dd', maxDate: '-1', onSelect: function (selected) { $(tu).datepicker("option", "minDate", selected) } }); $(tu).datepicker({ dateFormat: 'yy/mm/dd', changeMonth: true, changeYear: true, maxDate: '-1', onSelect: function (selected) { $(frm).datepicker("option", "maxDate", selected) } }); } }); </code></pre> <p>html is generated by php for ($a=1;$a&lt;=$i;$a++) {</p> <pre><code>echo(" &lt;li&gt; &lt;input type=\"text\" name=\"course_name$a\" class=\"jq_watermark required\" placeholder=\"Course Name\" title=\"$x Certified Course Name\" style=\"width:11.6em;\"&gt; &lt;tab&gt;&lt;/tab&gt; &lt;input type=\"text\" name=\"course_institute$a\" class=\"jq_watermark required\" placeholder=\"Institute Name\" title=\"$x Institute Name\" style=\"width:11.6em;\"&gt; &lt;tab&gt;&lt;/tab&gt; &lt;br /&gt; &lt;input type=\"text\" id=\"from$a\" name=\"course_start_date$a\" class=\"required\" placeholder=\"Certified Course Start Date\" title=\"$x Certified Course Start Date\" style=\"width:11.6em;\" readonly=\"readonly\"&gt; &amp;nbsp to&amp;nbsp &lt;input type=\"text\" id=\"to$a\" name=\"course_end_date$a\" class=\"required\" placeholder=\"Certified Course End Date\" title=\"$x Certified Course End Date\" style=\"width:11.6em;\"&gt; &lt;br /&gt; &lt;input type=\"text\" name=\"course_city$a\" class=\"required\" placeholder=\"City\" title=\"$x Training Institute City Name!\" style=\"width:11.6em;\"&gt; &lt;tab&gt;&lt;/tab&gt; &lt;input type=\"text\" name=\"course_country$a\" class=\" required\" placeholder=\"Country\" title=\"$x Training Institute Country Name!\" style=\"width:11.6em;\"&gt; &lt;tab&gt;&lt;/tab&gt; &lt;button title=\"Your Training Certificate Scanned Picture, Please!\"&gt;Upload Training Certificate&lt;/button&gt; &lt;/li&gt; "); </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload