Drop box coding help inquiry

So, this is in regard to my Level 3 radar stuff. I have been successful at creating different maps, i.e. composite reflectivity, base reflectivity, etc. I basically learn this stuff by copying what other people have done, but i am stuck.

I am trying to add a drop box with selection to pick the file to display, the composite reflectivity by itself works fine.
I have two variables here $l3map and $mapfile. I can’t seem to get any values into those variable. The line to echo the test never shows anything.

<br /><center> 
<span style="color:#000000; font-size:13px; font-family:arial, times new roman; font-size:large">
<b>Select Map Type:</b> &nbsp;
</span>

<select style="border:1px solid #000000; background-color:#FFFFFF; font-size:12px;" name="l3map">

  <option value="ComRefl"<?php echo $l3map=='ComRefl'? ' selected="selected"':""?>>Composite Reflectivity</option>
  <option value="BaseRefl"<?php echo $l3map=='BaseRefl'? ' selected="selected"':""?>>Base Reflectivity</option>
  <option value="BaseVel"<?php echo $l3map=='BaseVel'? ' selected="selected"':""?>>Base Velocity</option>
  <option value="StrmTr"<?php echo $l3map=='StrmTR'? ' selected="selected"':""?>>Storm Tracks</option>

</select>
</center>
<script type="text/javascript">
$("select").change(function () {
  var l3map = $(this).val();
});
</script>

<?php if ($l3map == 'ComRefl') {
	$mapfile = 'Level3.png';
}
else if ($l3map == 'BaseRefl') {
	$mapfile = 'BaseRf.png';
}
else if ($l3map == 'BaseVel') {
	$mapfile = 'BaseVel.png';
}
else if ($l3map == 'StrmTr') {
	$mapfile = 'StrmTr.png';
}

?>
<?php echo "test".$l3map;?><?php echo "test".$mapfile;?>

<center><h3>Level3 Radar</h3>
Click to open in a new frame<br />
<a href=<?php echo "../wddatafiles/".$mapfile?> target="_blank"><img src=<?php echo"../wddatafiles/".$mapfile; ?> width=640; height=400></a></center>
</div><!-- end main-copy -->

What might i be doing wrong in setting the values?
Thanks in advance.

Jim

I have the map showing, but when i select another option, it does not take it or act on it. Progress.

<select style="border:1px solid #000000; background-color:#FFFFFF; font-size:12px;" name="l3map" id="l3map">
  <option value="ComRefl"<?php echo $l3map='ComRefl'? ' selected="selected"':""?>>Composite Reflectivity</option>
  <option value="BaseRefl"<?php echo $l3map='BaseRefl'? ' selected="selected"':""?>>Base Reflectivity</option>
  <option value="BaseVel"<?php echo $l3map='BaseVel'? ' selected="selected"':""?>>Base Velocity</option>
  <option value="StrmTr"<?php echo $l3map='StrmTR'? ' selected="selected"':""?>>Storm Tracks</option>
</select>

<script src="$("select").change(function () {
  var l3map = $(this).val()})">
</script>

</center>
<?php if ($l3map = 'ComRefl') {
	$mapfile = 'Level3.png';
}
else if ($l3map = 'BaseRefl') {
	$mapfile = 'BaseRf.png';
}
else if ($l3map = 'BaseVel') {
	$mapfile = 'BaseVel.png';
}
else if ($l3map = 'StrmTr') {
	$mapfile = 'StrmTr.png';
}
?>

test <?php echo  $l3map?> test <?php echo $mapfile?>

Only the first one is acted on and it works to show the map.
Jim

You are mixing PHP and jQuery/javascript but those are executed on different moments.

The image is selected/displayed with PHP code
$l3map='BaseVel'?
before the user selects another map from the dropdown.

When the user selects another map a javascript field is modified
var l3map = $(this).val()
but changing l3map does not change the map which is already displayed.

Succes,
Wim

Thank you Wim, I understand what you are saying. I have been reading tutorials and examples of using POST and AJAX with an inc-whatever file, but the solution continues to evade me. There are a lot examples of this out there, but i just can’t quite get the implementation right.

Jim

I came up with a bit different way to achieve my goal. It’s kind of kludgey, but it works. Homemade Level 3 radar, Composite Reflectivity, Base Reflectivity, Base Velocity and Storm Tracks are up and running.

Now all i need is some rain.

Jim