First off, you're doing things a bit... uhm, well you're
making them more complicated than they need to be.
if ($from == '') { if $office == $corporate ...
The logic here is to use an AND statement.
<?php
if ((((empty($from)) AND ($office == 'corporate'))) OR ($from == 'corporate')) { echo "selected"; }
?>
That removes the mess. It also uses empty() instead of a blank
comparison, which also includes null and whitespace both.
Slightly easier to duplicate:
<?php
$location = 'corporate';
if ((((empty($from)) AND ($office == $location))) OR ($from == $location)) { echo "selected"; }
?>
Now just set $location as a test. I'd do this as function personally, but I won't
go that far yet.
[code:1:575ae55eed]
<td width="493">
<p align="left">Where are you coming from?
<select class="jumpmenu" name="from" onChange="MM_jumpMenu('parent',this,1)">
<option value="#">----------------------------- </option>
<option value="maps.php?office=corporate&from=corpus"
<?php
$location = 'corporate';
if ((((empty($from)) AND ($office == $location))) OR ($from == $location)) { echo "selected"; }
?>
>Corpus Christi</option>
<option value="maps.php?office=corporate&from=mcallen"
<?php
$location = 'mcallen';
if ((((empty($from)) AND ($office == $location))) OR ($from == $location)) { echo "selected"; }
?>
>McAllen</option>
<option value="maps.php?office=corporate&from=sanantonio"
<?php
$location = 'sanantonio';
if ((((empty($from)) AND ($office == $location))) OR ($from == $location)) { echo "selected"; }
?>
>San Antonio</option>
<option value="maps.php?office=corporate&from=houston"
<?php
$location = 'houston';
if ((((empty($from)) AND ($office == $location))) OR ($from == $location)) { echo "selected"; }
?>
>Houston</option>
<option value="maps.php?office=corporate&from=dallas"
<?php
$location = 'dallas';
if ((((empty($from)) AND ($office == $location))) OR ($from == $location)) { echo "selected"; }
?>
>Dallas</option>
<option value="#">For Clients </option>
<option value="#">----------------------------- </option>
</select></p>
[/code:1:575ae55eed]
This makes your code a LOT easier to read and debug. If something is wrong in the syntax, then it's wrong in all of them. I didn't test this beforehand, but it should give you a good idea about how you can proceed.
Now if you wanted to do a function then:
[code:1:575ae55eed]
<?php
function checkselected($location) {
global $from, $office;
if ((((empty($from)) AND ($office == $location)))
OR ($from == $location)) {
echo "selected";
}
}
?>
<td width="493">
<p align="left">Where are you coming from?
<select class="jumpmenu" name="from" onChange="MM_jumpMenu('parent',this,1)">
<option value="#">----------------------------- </option>
<option value="maps.php?office=corporate&from=corpus"
<?php checkselected('corporate'); ?>
>Corpus Christi</option>
<option value="maps.php?office=corporate&from=mcallen"
<?php checkselected('mcallen'); ?>
>McAllen</option>
<option value="maps.php?office=corporate&from=sanantonio"
<?php checkselected('sanantonio'); ?>
>San Antonio</option>
<option value="maps.php?office=corporate&from=houston"
<?php checkselected('houston'); ?>
>Houston</option>
<option value="maps.php?office=corporate&from=dallas"
<?php checkselected('dallas'); ?>
>Dallas</option>
<option value="#">For Clients </option>
<option value="#">----------------------------- </option>
</select></p>
[/code:1:575ae55eed]
Does that make sense? It may not work directly as written (might've missed a semicolon), but it's pretty dang close
