readdir & option value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Piotr Wolski

    #1

    readdir & option value

    more or less that is my problem:

    i'm making HTML <select><option > statement:

    if ($dir = @opendir("/the/directory)) {
    while($file = readdir($dir)) {

    echo '<option value="'.$file. '">'.$file;
    }
    }


    the number of options depends of number of files in directory.

    When user chooses one of this files(he chooses an option) i want to know
    what option he choosen.

    how can i do this?
  • Sauli Karhu

    #2
    Re: readdir &amp; option value

    Give the select control a name e.g. <select name="file">. Then the
    selected file will be in $_REQUEST['file'] when the form is submitted.

    -Sauli Karhu

    Piotr Wolski wrote:
    [color=blue]
    > more or less that is my problem:
    >
    > i'm making HTML <select><option > statement:
    >
    > if ($dir = @opendir("/the/directory)) {
    > while($file = readdir($dir)) {
    >
    > echo '<option value="'.$file. '">'.$file;
    > }
    > }
    >
    >
    > the number of options depends of number of files in directory.
    >
    > When user chooses one of this files(he chooses an option) i want to know
    > what option he choosen.
    >
    > how can i do this?[/color]

    Comment

    • Piotr Wolski

      #3
      Re: readdir &amp; option value

      Sauli Karhu wrote:[color=blue]
      > Give the select control a name e.g. <select name="file">. Then the
      > selected file will be in $_REQUEST['file'] when the form is submitted.
      >
      > -Sauli Karhu
      >
      > Piotr Wolski wrote:
      >[color=green]
      >> more or less that is my problem:
      >>
      >> i'm making HTML <select><option > statement:
      >>
      >> if ($dir = @opendir("/the/directory)) {
      >> while($file = readdir($dir)) {
      >>
      >> echo '<option value="'.$file. '">'.$file;
      >> }
      >> }
      >>
      >>
      >> the number of options depends of number of files in directory.
      >>
      >> When user chooses one of this files(he chooses an option) i want to
      >> know what option he choosen.
      >>
      >> how can i do this?[/color]
      >
      >[/color]
      $_POST['file'] exactly

      Comment

      Working...