Click here to Skip to main content
15,507,755 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to show respective colors for each areas if I select. Is that possible to make that? Colors for each areas are
J9AQR - green
J9KCN - maroon
2EAQR - blue
K8PAL - orange
GLWOTS - white

What I have tried:

Codes are as belows.

<pre><pre>$seal_area = array("J9AQR","J9KCN","2EAQR","K8PAL","GLWOTS");
	for($i=0;$i<count($seal_area);$i++) {
		$selected = ($seal_area[$i] == $site)? "selected" : "";
		$cbo_origsite .= "<option value=\"" . $seal_area[$i] . "\" " . $selected . ">" . $seal_area[$i] . "</option>";

<pre><label class="control-label col-sm-4" for="cboSiteOrig" style="margin-left: 1px;">Area:</label>
		   <div class="col-sm-4">
			<p class="form-control-static" style="margin-top: -6px;">
				<select class="form-control" id="cboSiteOrig" name="cboSiteOrig" onchange="OrigSiteChange(this.value)">
				<option value="" selected>Select Area</option>
	        	echo $cbo_origsite;

<pre>function OrigSiteChange(val){
	var orig_site = document.translot.cboSiteOrig.options[document.translot.cboSiteOrig.selectedIndex].value;
  var badgeno = document.translot.badgeno.value;
  var stat = document.translot.status.value;
  // $('#filter').html(''); // to clear bay selection

	AsynReqData(reqHttp,'filter.php?orig_site=' + orig_site + '&badgeno=' + badgeno + '&stat=' + stat,'RequestForm');
Updated 10-May-22 3:09am
Chris Copeland 10-May-22 5:03am    
There doesn't seem to be enough context on this question to make an educated answer, where are you trying to show the color and where is the code for the OrigSiteChange() method?
Kaung Khant Naing 10-May-22 5:07am    
Sorry, I've added javascript to the question. I want to appear colors beside of the drop down.

1 solution

I've put together a JSFiddle[^] with some example code that might be of use. You'll have to adapt it to match your own circumstances, but I guess it gives a general idea.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900