spires Posted April 8, 2008 Share Posted April 8, 2008 Hi Guys. Does anyone know how to display an array inside a textarea? What i'm trying to do select US state from a drop down menu, this then refreshes the page, creating an array that holds all of the US states. Then it should display the full list inside a textarea. Example: http://www.adwordstool.co.uk/test.php If you select 'US State' from the drop down, it should fill the top right textarea with the full list of states. But, it just says array. Heres some of the code: <!-- Array --> if ($alt=='US States'){ $state = array("Alabama, Alaska, Arizona, Arkansas, California, Colorado, Connecticut, Delaware, Florida, Georgia, Hawaii, Idaho, Illinois, Indiana, Iowa, Kansas, Kentucky, Louisiana, Maine, Maryland, Massachusetts, Michigan, Minnesota, Mississippi, Missouri, Montana, Nebraska, Nevada, New Hampshire, New Jersey, New Mexico, New York, North Carolina, North Dakota, Ohio, Oklahoma, Oregon, Pennsylvania, Rhode Island, South Carolina, South Dakota, Tennessee, Texas, Utah, Vermont, Virginia, Washington, West Virginia, Wisconsin, Wyoming"); } <!-- textarea --> <textarea name="ad_group" cols="38" rows="8" class="Forms" style="background-color:#FFFFCC" id="ad_group"> <?PHP $alt_text_array = explode(",", $state); foreach ($alt_text_array as $altText) { $altText = trim($altText); echo $altText; } ?> <!-- DropDown --> <select name="Alt" onChange="this.form.submit()"> <?PHP if ($alt){ echo '<option value="'.$alt.'" selected>'.$alt.'</option>'; echo '<option value="">------------</option>'; echo '<option value="US States">US States</option>'; echo '<option value="US Capitals">US Capitals</option>'; }else{ echo '<option value="" selected>Select Extentions</option>'; echo '<option value="US States">US States</option>'; echo '<option value="US Capitals">US Capitals</option>'; } ?> </select> </textarea> Thanks for any help\ Cheers Link to comment https://forums.phpfreaks.com/topic/100151-displaying-an-array/ Share on other sites More sharing options...
discomatt Posted April 8, 2008 Share Posted April 8, 2008 Why are you echo'ing a dropdown inside of a text area? They're two different form elements. Link to comment https://forums.phpfreaks.com/topic/100151-displaying-an-array/#findComment-512071 Share on other sites More sharing options...
spires Posted April 8, 2008 Author Share Posted April 8, 2008 The drop down is not is inside of the textarea These are just chuncks of code. each part of code is seperated with the : <!-- text --> However, I am using a foreach loop inside the text area Link to comment https://forums.phpfreaks.com/topic/100151-displaying-an-array/#findComment-512072 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.