Forum Moderators: coopster
<select name=\"centerPoint\" class=\"selectBoxes\">
<option";
if($centerPoint=="41.409775, -80.744018), 7") echo " SELECTED";
echo " value=\"41.409775, -80.744018), 7\">The Entire Area</option>
<option";
if($centerPoint=="41.849616, -79.143447), 11") echo " SELECTED";
echo " value=\"41.849616, -79.143447), 11\">Allegheny River - Kinzua Dam to Buckaloons Rec Area</option>
//get the first result if a category was selected
if(isset($_REQUEST['centerPoint']))
$centerPoint=$_REQUEST['centerPoint'];
//if no category was selected, these results won't exist, so define default values
if(!isset($centerPoint) or strlen($centerPoint)<1) $centerPoint="41.409775, -80.744018), 7";
// CREATE THE MAP
var map = new GMap2(document.getElementById(\"map\"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
// Set the center point of your map and set the zoom
map.setCenter(new GLatLng($centerPoint);
I assume this is after the user submits your form. Is it being sent by POST or GET?
also, is it not selecting the proper value? (I assume so or you wouldn't be posting ;))
have you viewed the source of the final page to see if it is possibly just an error in the html?
Here's a related thread [webmasterworld.com].
Note the use of the ternary operator [us3.php.net].
good luck!
<option";
if($centerPoint=="41.409775, -80.744018), 7") echo " SELECTED";
echo " value=\"41.409775, -80.744018), 7\">The Entire Area</option> be changed to this?
<option";
if($_POST['centerPoint'] == "41.409775, -80.744018), 7") echo " SELECTED";
echo " value=\"41.409775, -80.744018), 7\">The Entire Area</option>
<option value="41.409775, -80.744018, 7"
<?php
echo ($_POST['centerPoint'] == "41.409775, -80.744018, 7")? " SELECTED":"";
?>
>The Entire Area</option>
Your logic would work also, just you have some syntax errors. The above is just a more condensed version using the ternary operator.
[edited by: eelixduppy at 11:18 pm (utc) on Nov. 2, 2006]
//get the first result if a category was selected
if(isset($_REQUEST['centerPoint']))
$centerPoint=$_REQUEST['centerPoint'];
//if no category was selected, these results won't exist, so define default values
if(!isset($centerPoint) or strlen($centerPoint)<1) $centerPoint="41.409775, -80.744018), 7";
if(![url=http://us2.php.net/manual/en/function.empty.php]empty[/url]($_POST['centerPoint'])) {
$centerPoint = $_POST['centerPoint'];
} else {
$centerPoint = "41.409775, -80.744018), 7";
}
<select name="centerPoint" class="selectBoxes">
<option name="centerPoint" value="41.409775, -80.744018,) 7">The Entire Area</option>
<option name="centerPoint" value="41.849616, -79.143447), 11">Allegheny River - Kinzua Dam to Buckaloons Rec Area</option>
<option name="centerPoint" value="41.403941, -81.171562), 12">Cuyahoga River - Russell Park</option>
</select> I am able to select the second and third options and the will show selected but if I select the first option it never shows selected. Any ideas why?