Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Setting the Default Value for a dynamic select menu

Community Beginner ,
Dec 12, 2011 Dec 12, 2011

Hi I have a php page with 2 forms on it, one feeds the other to achieve a drill down (manufacturer > model). In the second select menu I have a default static value "Select Aircraft Model", I want to set a value for the first dynamic select menu to read "Select Aircraft Manufacturer". When I add a static value to my list it tells me I alreay have a dynamic behavior on this menu and to choose a different one. I have included the code for both menus. Thank you in advance, I know this must be a stupid question, but it's got me stumped.

Tom

//This is the menu I want to add the default static value to//

<td width="667"><select name="airMake" style="width: 200px;"onchange="this.form.submit();" id="airMake">

        <?php

do {

?>

        <option value="<?php echo $row_rsAirManufacturer['aircraft_manufacturer']?>"<?php if (!(strcmp($row_rsAirManufacturer['aircraft_manufacturer'], ((isset($_POST["airMake"]))?$_POST["airMake"]:"")))) {echo "selected=\"selected\"";} ?>><?php echo $row_rsAirManufacturer['aircraft_manufacturer']?></option>

        <?php

} while ($row_rsAirManufacturer = mysql_fetch_assoc($rsAirManufacturer));

  $rows = mysql_num_rows($rsAirManufacturer);

  if($rows > 0) {

      mysql_data_seek($rsAirManufacturer, 0);

      $row_rsAirManufacturer = mysql_fetch_assoc($rsAirManufacturer);

  }

?>

      </select>

      </td>

  </tr>

</table></form>

 

    <form action="quoteResult.php" method="post" name="quoteForm">

      <table width="100%" border="0" cellpadding="5px">

        <tr>

          <td width="260"style="color: #000; text-align: right;">Aircraft Model:</td>

          <td colspan="2"><span id="spryselect2">

//This is the menu that works correctly//

            <select name="airModel" style="width: 200px;" id="airModel">

              <option value="" <?php if (!(strcmp("", ((isset($_POST["airMakeField"]))?$_POST["airMakeField"]:"")))) {echo "selected=\"selected\"";} ?>></option>

              <?php

do { 

?>

              <option value="<?php echo $row_rsAirModel['aircraft_model']?>"<?php if (!(strcmp($row_rsAirModel['aircraft_model'], ((isset($_POST["airMakeField"]))?$_POST["airMakeField"]:"")))) {echo "selected=\"selected\"";} ?>><?php echo $row_rsAirModel['aircraft_model']?>Select Aircraft Model</option>

              <?php

} while ($row_rsAirModel = mysql_fetch_assoc($rsAirModel));

  $rows = mysql_num_rows($rsAirModel);

  if($rows > 0) {

      mysql_data_seek($rsAirModel, 0);

      $row_rsAirModel = mysql_fetch_assoc($rsAirModel);

  }

?>

              </select>

TOPICS
Server side applications
689
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Dec 15, 2011 Dec 15, 2011

Change this -

<select name="airMake" style="width: 200px;"onchange="this.form.submit();" id="airMake">

to this -

<select name="airMake" style="width: 200px;"onchange="this.form.submit();" id="airMake">

<option value="-1">Select Aircraft Manufacturer</option>

Then if the value of 'airMake' is -1 you know that no choice was made.

Translate
LEGEND ,
Dec 15, 2011 Dec 15, 2011

Change this -

<select name="airMake" style="width: 200px;"onchange="this.form.submit();" id="airMake">

to this -

<select name="airMake" style="width: 200px;"onchange="this.form.submit();" id="airMake">

<option value="-1">Select Aircraft Manufacturer</option>

Then if the value of 'airMake' is -1 you know that no choice was made.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 18, 2011 Dec 18, 2011
LATEST

That worked beautifully, thank you so much

Tom

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines