Note that there are some explanatory texts on larger screens.

plurals
  1. POshow multiple selected values of drop-down after submit if error comes on form
    primarykey
    data
    text
    <p>I have this drop-down and user can select multiple options ,how can i keep selected value on form after submit button, if error comes on form</p> <pre><code>&lt;th align="right" style="width: 264px"&gt;&lt;label id="lcell"&gt;*Preferred City for Relocation Work :&lt;/label&gt;&lt;/th&gt; &lt;td&gt;&lt;select onchange="document.getElementById('cand_pref').style.display='none';" name="pcity[]" id="pcity" multiple="multiple" &gt; &lt;?php $pcitylist = array( 'Mizoram' =&gt; array('Aizawl', 'Champhai', 'Kolasib', 'Lawngtlai', 'Lunglei', 'Mamit', 'Saiha', 'Serchhip'), 'Nagaland' =&gt; array('Dimapur', 'Kohima', 'Mokokchung', 'Mon', 'Phek', 'Tuensang', 'Wokha', 'Zunheboto'), 'Orissa' =&gt; array('Angul', 'Boudh', 'Bhadrak', 'Bolangir', 'Bargarh', 'Baleswar', 'Cuttack', 'Debagarh', 'Dhenkanal', 'Ganjam', 'Gajapati', 'Jharsuguda', 'Jajapur', 'Jagatsinghpur', 'Khordha', 'Kendujhar', 'Kalahandi', 'Kandhamal', 'Koraput', 'Kendrapara', 'Malkangiri', 'Mayurbhanj', 'Nabarangpur', 'Nuapada', 'Nayagarh', 'Puri', 'Rayagada', 'Sambalpur', 'Subarnapur', 'Sundargarh'), 'Puducherry' =&gt; array('Karaikal', 'Mahe', 'Puducherry', 'Yanam') ); 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; </code></pre>
    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.
 

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