hi all,
pls help... this is my code from where i can select multiple values and post... but it is not displaying the selected values in multiple dropdownlist... how can i solve this????

$loc_con1 = array(1=>'ALL','Andaman and Nicobar Islands','Andhra Pradesh', 'Arunachal Pradesh','Assam', 'Bihar','Chandigarh','Chhattisgarh','Dadra and Nagar Haveli','Daman and Diu','Delhi','Goa','Gujarat','Himachal Pradesh','Jammu and Kashmir','Jharkhand','Karnataka','Kerala','Lakshadweep','Madhya Pradesh', 'Maharashtra','Manipur','Meghalaya','Mizoram','Nagaland','Orissa','Pondicherry','Punjab','Rajasthan','Sikkim','Tamil Nadu','Tripura','Uttaranchal','Uttar Pradesh','West Bengal');



<select name="loc_considered[]" multiple="multiple">

    if($loc_con1[$j] == $loc_con[$i])

     echo '<option value="'.$loc_con1[$j].'" selected="selected">'.$loc_con1[$j].'</option>\n';

        echo '<option value="'.$loc_con1[$j].'" >'.$loc_con1[$j].'</option>\n';


Recommended Answers

All 4 Replies

change line number 13 with follwing line, comment your if condtion

if (in_array($loc_con1[$j], $loc_con))

Did you analyze your html in a browser after worked script? There are elements "option" with attribute "selected="selected""
Maybe condition "if($loc_con1[$j] == $loc_con[$i])" never don't cause.

tnx.... urtrivedi

now its working.... i did as like u said....

i have some problem to, i want to display 2 column in a select box PHP, which is reff_number and name from same table , pelanggan table, please help me, here'e the code

/Users/ariasoewartono/Desktop/Screen Shot 2016-05-25 at 1.13.28 PM.png

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.