Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Auto populate textbox after selecting an item from my listmenu or combobox
Index -> Programming, PHP -> PHP Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
waltg72




PostPosted: Mon Aug 30, 2010 5:50 am   Post subject: Auto populate textbox after selecting an item from my listmenu or combobox

I am just starting to learn php and mysql as database. Is there a way to use my data stored from my mysql table as my option list to my list menu in php? Then once I select one of those data displayed from my listmenu, i want to display the item also in a textbox. Is this possible? How? can someone give me a php sample for this? I am spending weeks trying to figure out how to do this stuff. Thanks in advance.
Sponsor
Sponsor
Sponsor
sponsor
DanShadow




PostPosted: Wed Sep 22, 2010 2:07 pm   Post subject: Re: Auto populate textbox after selecting an item from my listmenu or combobox

It's pretty easy actually Smile.

I'm running a bit late today, so ill just give you pseudo-code.

Danshadow wrote:

$array = LOAD_DB_ROW_DATA;

echo "<form action='PAGE.PHP' method='post'>";

echo "<select name='FORM SUBMISSION POST NAME'>";

for ($i = 0; $i < count($array); $i++) {
echo "<option value='" . $array[$i] . "'>";
echo $array[$i];
echo "</option>";
}

echo "</select>";

echo "<input type='Submit' value='Submit Selection!'>";

echo "</form>";

echo "<br><br>";

if (!empty($_POST["FORM SUBMISSION POST NAME"])) {
echo "<input type='text' value='" . $_POST["FORM SUBMISSION POST NAME"] . "'>";
}


You load the DB row values into an array, populate a dropdown menu with the items (doesnt have to be a dropdown menu), and add a submission form.
The bottom checks if a post value has been submitted, and if it has it will set the value of the text box with the selected "option" in the previous form.

Hope that helps.
Display posts from previous:   
   Index -> Programming, PHP -> PHP Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: