php - Trying to echo an image source in a select option list
724
I have a php loop where I am trying to echo a HTML image source inside the select option tag, like this:
foreach($recs as $i){
if($i->isscripted == 1){
$is = "<img src='greencheck.gif'>";
}else{
$is = "<img src='redbang.gif'>";
}
echo "<option value=".$i->id.">".$is." ".$i->fullname."</option>";
}
The image is not displaying in the select list. I tested the image tag outside of the loop and it displays fine.
echo "<img src='greencheck.gif'>";
Answer
Solution:
You cannot do it using pure HTML, but there are a few workarounds:
CSS Background (Works only in firefox):
Using a jQuery Plugin
http://www.queness.com/resources/images/formplugin/22.gif
Answer
Solution:
A nice solution from vartec
You can try it and thanks to him
Click Here
Answer
Solution:
You can use:
Answer
Solution:
You cant have images inside
<option>
,it can take only textual options, you will need to get it out and maybe do some javascript or jquery to display the image somewhere else when you select an option. There are also Jquery pluggins that can do this as http://designwithpc.com/Plugins/ddSlick