CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2013
    Posts
    4

    Select List keep selected value after auto submit

    Hi,

    I have a select list as seen below and I want to keep the selected value after it automatically selects can anyone help please? I have tried a few things using javascript but nothing seemed to work.

    Code:
    <select name="inteu_06" onchange="this.form.submit()" style="margin-right:0px">
            <option value="~">Price Limit - Any</option>
            <?php
    do {  
    ?>
            <option value="<?php echo $row_Recordset1['inteu_06']?>"><?php echo $row_Recordset1['inteu_06']?></option>
            <?php
    } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
      $rows = mysql_num_rows($Recordset1);
      if($rows > 0) {
          mysql_data_seek($Recordset1, 0);
    	  $row_Recordset1 = mysql_fetch_assoc($Recordset1);
      }
    ?>
          </select>
    Many thanks
    Joe

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: Select List keep selected value after auto submit

    [ moved thread ]
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    May 2002
    Posts
    10,943

    Re: Select List keep selected value after auto submit

    You need to create a selected attribute for the on that matches.

    PHP Code:
    <option <?php if ($_POST['inteu_06'] == $row_Recordset1['inteu_06']) {?> selected="selected"<?php ?> value="<?php echo $row_Recordset1['inteu_06']; ?>"><?php echo $row_Recordset1['inteu_06']; ?></option>
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured