Connecting Tech Pros Worldwide Forums | Help | Site Map

select option

kirke
Guest
 
Posts: n/a
#1: Oct 19 '06

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.php">
<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)$_POST['dayList'];
?>

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


Pedro Graca
Guest
 
Posts: n/a
#2: Oct 19 '06

re: select option


kirke wrote:
Quote:
<form name="form1" method="post" action="next.php">
<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)$_POST['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']);
?>
Quote:
<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
Closed Thread