Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

How 2 create a dynamic list/menu from a list/menu that is not dynamic?

The page in question is: http://www.c21reu.com/addProperty.php. And the part that needs solving is the "Choose a Property Type" field.

Currently this Property Type field has these categories:Acreage; Commercial: Farm; Lot; Multi-Family; Residential; Townhouse.

When the office manager at Century 21 Real Estate Unlimited goes in to edit a property listing, all of the information loads in correctly except the Property Type box. She has to go and reselect the property type.

I want the problem to be solved such that she doesn't have to reselect it - the property type loads in as does the other information.
  • 3
1 Solution
The syntax should be the same as it is for the 'Select Agent Name' field as they are both the same kind of menu.  Is 'Select Agent Name' working?
To indicate which item in the drop down is selected simply fill an array variable with the word "selected".

For instance;

Let's say that your query returned a value for the drop down of 2, Commercial.

You could write something like this..,

$returnedValue  =  $row['myField'];

$myArray[$returnedValue  =  'selected';

<select name="selMyDropDown">
    <option value="1" <?=$myArray[1]?>>Acreage</option>
    <option value="2" <?=$myArray[2]?>>Commercial</option>
    <option value="3" <?=$myArray[3]?>>Farm</option>

This will put selected in the value for $myArray[2] and the dropdown will show Commercial as the selected item when the page loads.
The objective is to have the result stored in the database appear as a pre-selected choice in the drop-down menu.  To do this in Dreamweaver: select the drop-down menu so that the properties window appears, click the 'Dynamic' button to bring up the 'Dynamic List/Menu' window.  In the 'Dynamic List/Menu' window, click little button with the lightning symbol beside the 'Select Value Equal To' field - this will bring up the 'Dynamic Data' winsow with the recordset applicable to that form.  Scroll down to find the recordset value you want (ie. property_type or whatever it's called in your database table), select it and click OK.

Here is an example of the code generated from a PHP/MySQL real estate site I developed:

<select name="Property Type" id="property_type">
<option value="Detached" <?php if (!(strcmp("Detached", $row_rsListings['type']))) {echo "selected";} ?>>Detached</option>
<option value="Semi-Detached"   . . .   etc.
MaryAnnWalshAuthor Commented:
I do have an objection to the Administrative Comment from modulo.

The Forced Accept should not go to alexhogan {http:#13753729} because I could not use an array. I needed instructions that would pull information dynamically from a database.

The credit should go to the answer from: humeniuk {http:#13753844} because these are the instructions that work.

I realize I forgot about this posted question/answer of  Date: 04/11/2005 10:35AM EST
This post is within the four day time limit for my response to ask that the credit go to humeniuk who actually gave me the correct answer.

Mary Ann Walsh
It's good to know the info was helpful.  Thank you for the A.

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now