select option

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

    #1

    select option


    I want to load textarea's value in drop-down box.
    In first page, such form is existed.


    <form name="form1" method="post" action="next.ph p">
    <textarea name="dayList" Id = "dayList" cols=20
    rows=10></textarea>
    </form>

    in text area there's one column of values.


    in "next.php", put values of 'dayList' in select option. I made a code
    by myself. However, as you see, it's just nonsense. How can I modify
    this? Thank you!



    <?php
    $value=(int)$_P OST['dayList'];
    ?>

    <select name="dateList" id="dateList" >
    <?php
    echo '<option value="1">' .$value '</option>';
    ?>
    </select>

  • Pedro Graca

    #2
    Re: select option

    kirke wrote:
    <form name="form1" method="post" action="next.ph p">
    <textarea name="dayList" Id = "dayList" cols=20
    rows=10></textarea>
    </form>
    >
    in text area there's one column of values.
    >
    >
    in "next.php", put values of 'dayList' in select option. I made a code
    by myself. However, as you see, it's just nonsense. How can I modify
    this? Thank you!
    >
    >
    >
    <?php
    $value=(int)$_P OST['dayList'];
    ?>
    $_POST['dayList'] is a list of lines, not an int!
    You want to convert a group of lines into an array.

    <?php
    $value = explode("\n", $_POST['dayList']);
    ?>
    <select name="dateList" id="dateList" >
    <?php
    echo '<option value="1">' .$value '</option>';
    ?>
    </select>
    <select name="dateList" id="dateList">
    <?php
    foreach ($value as $k=>$v) {
    echo '<option value="', $k, '">', $v, '</option>';
    }
    ?>
    </select>

    --
    File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot

    Comment

    Working...