By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,686 Members | 1,558 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,686 IT Pros & Developers. It's quick & easy.

select option

P: n/a

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>

Oct 19 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
kirke wrote:
<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']);
?>
<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
Oct 19 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.