keeping values on php form after submit if error comes on form
<p>This code i am using to select multiple values in dropdown with some jqueries</p>

<pre><code>&lt;script type="text/javascript"&gt;           
    $(document).ready(function() {
        $("#s1").dropdownchecklist();
        $("#s2").dropdownchecklist( {icon: {}, width: 150 } );
        $("#s3").dropdownchecklist( { width: 150 } );
        $("#s4").dropdownchecklist( { maxDropHeight: 150 } );
        $("#s5").dropdownchecklist( 
            { firstItemChecksAll: true, explicitClose: '...close' } );
        $("#s6").dropdownchecklist();
        $("#s7").dropdownchecklist();
        $("#s8").dropdownchecklist( { emptyText: "Please Select...", width: 150 } );
        $("#s9").dropdownchecklist( { textFormatFunction: function(options) {
            var selectedOptions = options.filter(":selected");
            var countOfSelected = selectedOptions.size();
            switch(countOfSelected) {
                case 0: return "&lt;i&gt;Nobody&lt;i&gt;";
                case 1: return selectedOptions.text();
                case options.size(): return "&lt;b&gt;Everybody&lt;/b&gt;";
                default: return countOfSelected + " People";
            }
        } 
    });
    $("#pcity").dropdownchecklist({ emptyText: "Please select ...", width: 500 },{ maxDropHeight: 150 }, { forceMultiple: true
, onComplete: function(selector) {
    var values1 = "";
    for( i=0; i &lt; selector.options.length; i++ ) {
        if (selector.options[i].selected &amp;&amp; (selector.options[i].value != "")) {
            if ( values1 != "" ) values1 += ",";
                values1 += selector.options[i].value;               
        }
    }
    alert( values1 );
} 
, onItemClick: function(checkbox, selector){
    var justChecked = checkbox.prop("checked");
    var checkCount = (justChecked) ? 1 : -1;
    for( i = 0; i &lt; selector.options.length; i++ ){
        if ( selector.options[i].selected ) checkCount += 1;
    }
    if ( checkCount &gt; 3 ) {
        alert( "Limit is 3" );
        throw "too many";
    }
}
            });
</code></pre>

<p>I have this Code for city dropdown ,but when some error comes on form after submit ,values does not remain on form ,but with same code on other dropdowns in which i am not using above script values remain on form after submit if some error comes ,pls have some suggesions,thankyou.</p>

<pre><code>&lt;tr&gt;
    &lt;td&gt; 
        &lt;select name="pcity[]" id="pcity" multiple="multiple" style="display: none"&gt;
        &lt;?php
            $pcitylist =  array(
        'Andaman and Nicobar' =&gt; array(
        'North and Middle Andaman', 'South Andaman', 'Nicobar'
    ),
    'Andhra Pradesh' =&gt; array(
        'Adilabad', 'Anantapur', 'Chittoor', 'East Godavari', 'Guntur', 'Hyderabad', 'Kadapa', 'Karimnagar', 'Khammam', 'Krishna', 'Kurnool', 'Mahbubnagar', 'Medak', 'Nalgonda', 'Nellore', 'Nizamabad', 'Prakasam', 'Rangareddi', 'Srikakulam', 'Vishakhapatnam', 'Vizianagaram', 'Warangal', 'West Godavari'
    ),
    'Arunachal Pradesh' =&gt; array(
        'Anjaw', 'Changlang', 'East Kameng', 'Lohit', 'Lower Subansiri', 'Papum Pare', 'Tirap', 'Dibang Valley', 'Upper Subansiri', 'West Kameng'
    ),
    );

    foreach ($pcitylist as $key =&gt; $pcitylist1)
    {
      echo '&lt;optgroup label="'.$key.'"&gt;';
      foreach ($pcitylist1 as $finalCity) {
          echo '&lt;option value="' . $finalCity . '"' . (isset($_POST['pcity']) &amp;&amp; $_POST['pcity'] == $finalCity ? ' selected' : '') . '&gt;' . $finalCity . '&lt;/option&gt;';
      }   
      echo '&lt;/optgroup&gt;';
} 
?&gt;
&lt;/select&gt;

    &lt;/td&gt;
&lt;/tr&gt;
</code></pre>
