Ankündigung

Einklappen
Keine Ankündigung bisher.

[Erledigt] Ausgewähltes Dorpdown Element in Textfeld übernehmen

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • [Erledigt] Ausgewähltes Dorpdown Element in Textfeld übernehmen

    Hallo Community,

    ich hätte eine Frage bezüglich der Datenübernahme aus eine DropDown Liste.

    auf der Hauptseite habe ich folgende Dropdownliste, welche durch eine Arrayvariable gefüllt wird.

    Host.php:
    PHP-Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
      <title>Host Config </title>
      <meta http-equiv="content-type" content="text/html; charset=utf-8">
    </head>

    <body>  
    <br>
    <div align="left"><table>
        <tr>
            <th>
    <form action="host_edit.php" method="post"><input type="submit" name="host_edit" value="edit Host">
    <?PHP
    include_once('host_functions.php');
    if (!empty(
    $_POST['host']))
    {
    $Host = new Host;
    $hostname $Host->read_cfg_hostnames();  
    }
    echo
    '<select name="host_select">';
            foreach(
    $hostname as $key=>$value)
                {
                    echo
    '<option value="'.$value.'">'.$value.'</option>';
                }
                echo 
    '</select>';            
    ?>
    <p>
    </form>
    </th>
    </tr>
    </table>
    </body>
    </html>
    Auf einer zweiten Seite soll das ausgewählte Element in einer Textbox vorgegeben werden.

    host_edit.php:
    PHP-Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
      <title> </title>
      <meta http-equiv="content-type" content="text/html; charset=utf-8">
    </head>

    <body>
    <div align="left"><table>
    <tr>
        <th>
            <form action="host_functions.php" method = "post" >
            <p>Hostname: <input name="hostname" value=$_POST['host_select'] readonly="readoly"/> </p>
            </th></tr>
            <tr><th>
            <p>IP: <input name="ip"/></p>
            </th></tr>
            <tr><th>
    <?PHP
            
    include_once('host_functions.php');
            if (!empty(
    $_POST['new_host']))
            {
                
    $Hostgroup = new Hostgroup;
                
    $hostgroups $Hostgroup->read_hostgroup();
            }
            echo
    '<select multi="multiple" name="hostgroup[]">';
            foreach(
    $hostgroups as $key=>$value)
            {
                echo 
    '<option value="'.$value.'">' .$value'</option>';
            }
            echo 
    '</select>';
            
    ?>
            </tr></th>
            <tr><th>
            <p>Alias: <input name="alias" /> </p>
            </th></tr>
            </form>
            </table>

    </body>
    </html>

    Ich seh meinen Fehler aktuell leider nicht.

  • #2
    Code:
    value=$_POST['host_select']
    An der Stelle musst du natürlich auch Anführungszeichen, PHP-Tags und echo verwenden.
    [I]You know, my wife sometimes looks at me strangely. „Duncan“, she says, „there's more to life than Solaris“. Frankly, it's like she speaks another language. I mean, the words make sense individually, but put them together and it's complete nonsense.[/I]

    Kommentar


    • #3
      <input name="hostname" value="<?php echo $_POST['host_select']; ?>" readonly="readoly"/>

      Kommentar


      • #4
        Ich habe versucht es wie folgt zu realisieren:

        PHP-Code:
        ...
        <?php 
        echo "Hostname: <input name='hostname' value=".$_POST['host_select']."/>";?>
        ...
        Die Ausgabe von var_dump($_POST['host_select']) ergab leider NULL.
        Server-log: "PHP Notice: Undefined index: host_select"


        Der Wert von $_POST['host_select'] kommt von dieser Auswahlliste:

        PHP-Code:
        ...
        <form action="host_edit.php" method="post"><input type="submit" name="host_edit" value="edit Host">
        <?PHP
        include_once('host_functions.php');
        if (!empty(
        $_POST['host']))
        {
        $Host = new Host;
        $hostname $Host->read_cfg_hostnames();  
        }
        echo
        '<select name="host_select">';
                foreach(
        $hostname as $key=>$value)
                    {
                        echo
        '<option value="'.$value.'">'.$value.'</option>';
                    }
                    echo 
        '</select>';            
        ?></form>
        ...
        Ich denke ich habe mein Problem gefunden. Da ich kein <input type="submit"> definiert habe werden die Daten nicht gesendet.

        Kommentar


        • #5
          Mit

          PHP-Code:
          <form action="host_edit.php" method="post">
          <?PHP
          include_once('host_functions.php');
          if (!empty(
          $_POST['host']))
          {
          $Host = new Host;
          $hostname $Host->read_cfg_hostnames();  
          }
          echo
          '<select name="host_select">';
                  foreach(
          $hostname as $key=>$value)
                      {
                          echo
          '<option value="'.$value.'">'.$value.'</option>';
                      }
                      echo 
          '</select>';        
          ?><p>
          <input type="submit" name="sent data" value="add_Host" />
          </form>
          klappt die Datenübernahme.

          Kommentar

          Lädt...
          X