Hi All,
I'm having problems coding what no doubt should be a very simple thing:
I have mobile XHTML form that contains a dropdown list and a textarea, the user selects an item from the list, click an Add button and the item from the list gets added to the textarea. I have the basic stuff down and working - but my grasp of PHP is limited (this is my first go with it...) and I need to know how to:
1) Add the selected item to the textbox (each item to it's own line)
2) Then redisplay the XHMTL page showing the item added to the textbox.
Thanks for any help!
Listboxes items --> textarea
Moderator: General Moderators
A little snippet to get the selected items in a listbox:
http://timvw.madoka.be/programming/php/ ... ltiple.txt
$text = $_POST['text']; // get what there is already in the textarea
Now all you have to do is iterate over the item, and append the values and a "<br/>" to $text to generate a linebreak effect in html.
Finally echo "<textarea name='text'>{$text}</textarea>";
http://timvw.madoka.be/programming/php/ ... ltiple.txt
$text = $_POST['text']; // get what there is already in the textarea
Now all you have to do is iterate over the item, and append the values and a "<br/>" to $text to generate a linebreak effect in html.
Finally echo "<textarea name='text'>{$text}</textarea>";
Tim,
Thanks! I can follow most of that
, however, I need to get the updated $text back into the textarea it came out of, not display it as HTML text on new/ existing screen - which is what I think the echo command does - right?
See below -
http://www.ximetrix.ca/portal.html
The intent is to use the drop down to help speed up data entry from a mobile device... so the user picks a command from the dropdown - clicks the insert button- at which point the XHTML page is somehow updated/ reloaded via PHP (unless you know another way) to show the selected command inserted in to the textarea. The user might have to select several comamnds, and add additional text to eachline hence the use of the textarea. Follow?
Can I do this in PHP - of do I need to look at coding it up in something like JAVA...
Over,
Ian

Thanks! I can follow most of that
See below -
http://www.ximetrix.ca/portal.html
The intent is to use the drop down to help speed up data entry from a mobile device... so the user picks a command from the dropdown - clicks the insert button- at which point the XHTML page is somehow updated/ reloaded via PHP (unless you know another way) to show the selected command inserted in to the textarea. The user might have to select several comamnds, and add additional text to eachline hence the use of the textarea. Follow?
Can I do this in PHP - of do I need to look at coding it up in something like JAVA...
Over,
Ian
Sorry - form is at http://www.ximetrix.ca/portal.xhtml
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
errr thats a little hard to understand but i think what you are saying is that you want to cick on the insert button and it will add "Option A" to the text area. then the user selects "Option B" and hits insert and the textarea then displays
Option A
Option B
and so on. that what you are looking for? if so do somtin like this
Jcart | fixed parse error
Option A
Option B
and so on. that what you are looking for? if so do somtin like this
Code: Select all
<select name="somthing">
<option value="1">Option A</option>
<option value="2">Option B</option>
</select>
<input type="submit" name="submit" value="insert">
<?
if ($_POST['submit'])
{
echo '<input type="hidden" name="already_selected[]" value="'.$_POST[somthing].'">';
}
echo '<textarea name="coolba">';
if (is_array($_POST['already_selected']))
{
foreach ($_POST['already_selected'] as $key => $value)
{
echo $value;
}
}
echo $_POST['somthing'];
echo '</textarea>';
?>