html listbox to show additonal txt in extra field outside of listbox
I have the following db-retrieve which results in the Listbox I like to have. But I need $desc2 to be shown under the listbox in a separate field and 开发者_开发问答it must change its content when the user clicks on an other item in the list:
Here is the retrieve which works:
echo "<form action=\"admin.php\" method=\"post\">";
echo "Industry:<SELECT name=\"industry\" size=\"10\">";
$result=sql_query("SELECT cat, title, desc, parentid
FROM industries
WHERE language='english'");
while(list($cid2, $ctitle2, $desc2, $parentid2) = sql_fetch_row($result)) {
if ($cid2==$userindustry) {
$sel = "selected";
} else {
$sel = "";
}
if ($parentid2!=0) $ctitle2=getparentindustry($parentid2,$ctitle2);
echo "<option value=\"$cid2\" $sel>$ctitle2</option>";
}
echo "</SELECT>
<br>$desc2<br> # place to show description of list item
<input type=\"hidden\" name=\"op\" value=\"save\">
<input type=\"submit\" value=\"Go\"></form><br>";
As I'm now searchin for some time, but didn't found something, hopefully someone here could help me.
The code for the side is in php.
Thanks in advance.
You would have to store $desc2 to a temporary variable in the loop, and use the temporary variable after the select to show the temporary variable.
I would however, point out that in general, this is probably the wrong way of going about this code, and that your problem is deeper in your implementation :)
精彩评论