selected option value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wizardry
    New Member
    • Jan 2009
    • 201

    selected option value

    hello -

    i'm using a select statement and its not setting the selected value from the menu.

    i've tried to echo the id for the selected item but its just coming back as the first record in the list.

    i.e. menu - resume -
    - calendar -
    - phone book -

    when i select calendar it still show record set resume was selected.

    thanks for your help in advance.

    theo werntz

    Code:
    <td>Select file to Upload to: <?php echo $row_file['id'] ; ?><select name="fileid" id="fileid" >
      <?php
    do {  
    ?>
      <option value="<?php echo $row_file['Id']?>"<?php if (!(strcmp($row_file['Id'], $row_file['Id']))) {echo "selected=\"selected\"";} ?>><?php echo $row_file['file']?></option>
      <?php
    } while ($row_file = mysql_fetch_assoc($file));
      $rows = mysql_num_rows($file);
      if($rows > 0) {
          mysql_data_seek($file, 0);
    	  $row_file = mysql_fetch_assoc($file);
      }
    ?>
    </select>
  • wizardry
    New Member
    • Jan 2009
    • 201

    #2
    ok it will post the id if not forwarding.

    my form has an action to it that needs to send the value to it from the selected option menu.

    I know how to pass them through the url, with get/post.

    but this is giving me my leg work thats for sure.

    how do i get it to pass the variable? because as soon as i press submit it calls the action from the form.

    i dont want my users to have to do 2 submits.

    thanks in advance for your help!

    theo werntz

    Comment

    • wizardry
      New Member
      • Jan 2009
      • 201

      #3
      solution i hide the underlying form then on submit of the choosen object it un hide it and set that selected variable. and it was passed as well.

      Comment

      Working...