I've dug through many posts but can't find a scenario quite like this on here...
I have a PHP form that contains a dropdown selection containing option values from a MySQL database table. This part works fine. Here's where I need help...
There is a textarea field that I need to populate with data from the same database table, but a different field. This table contains a 'name' and a corresponding set of 'text'. The dropdown shows the 'name' as the options. So what I need is when a selection is made, a script runs (like onChange)... takes the selected value, queries the database to get the 'text' that is associated with the selected 'name'. That 'text' is then displayed inside of the textarea form field.
A section of this code for you to view is:
echo "<form action=$PHP_SELF method=\"post\">\n";
echo "<select id=\"conditions\" name=\"conditions\">\n";
echo "<option value=\"Select\" selected>Select a Message</option>\n";
$result = mysqli_query($link, "SELECT * FROM db_scripts");
while ($data = mysqli_fetch_object($result)) {
echo "<option value=".$data->script_id.">".$data->script_name."</option>\n";
}
echo "</select>\n";
echo "<br><textarea name=\"message\" style=\"width:300px; height:130px\" data-maxsize=\"160\" data-output=\"status1\" wrap=\"virtual\" maxlength=\"160\"></textarea><br />\n";
So, like I said, this part works just fine. I have the dropdown with the 'script_name' as the options. Now I just need to get the corresponding message into the textarea field "message". Any assistance is most appreciated!