Return select dropdown in ajax call PHP

Sektorator

New Member
I want to fetch dropdown list in ajax call using PHP code.\[code\]$outputRes = '';$reminderDetails["interval_type"] = value of dropdown this may varies. I want to keep value selected="selected"\[/code\]Below is my expected output from ajax call\[code\]$outputRes .= '<select id="reminder_int_type" name="reminder_int_type" class="change"> <option value="http://stackoverflow.com/questions/15631255/1" '.if($reminderDetails["interval_type"] == 1){ \'selected="selected"\'; }.'>days</option> <option value="http://stackoverflow.com/questions/15631255/2">Hours</option> <option value="http://stackoverflow.com/questions/15631255/3">Minutes</option> </select>';echo $outputRes; exit;\[/code\]I may use code like below but i have many options tag so doesn't look feasible to me\[code\]$outputRes .= '<select id="reminder_int_type" name="reminder_int_type" class="change"> <option value="http://stackoverflow.com/questions/15631255/1" ';if($reminderDetails["interval_type"] == 1){ $outputRes .= 'selected="selected"';}$outputRes .= '>days</option> <option value="http://stackoverflow.com/questions/15631255/2">Hours</option> <option value="http://stackoverflow.com/questions/15631255/3">Minutes</option> </select>';echo $outputRes; exit;\[/code\]I have problem in writting right syntax .
 
Back
Top