Need help on how to pass the selected value in a form to the DB
Here goes
echo "<form name=\"Register\" action=\"modules.php\" method=\"post\">";
some irrelevant code
..
..
and then the select box
echo "<select name=\"user_avatar\" onChange=\"showimage()\" class=\"pn-normal\">";
$handle = opendir('images/avatar');
while ($file = readdir($handle)) {
$filelist[] = $file;
}
asort($filelist);
while (list ($key, $file) = each ($filelist)) {
ereg(".gif|.jpg", $file);
if ($file != "." && $file != ".." && $file != "index.html" && $file != "CVS") {
echo "<option value=\"$file\"";
if ($file == $user_avatar) {
echo " selected";
}
echo ">$file</option>";
}
}
echo "</select>";
echo "</font></td>"
."</tr>";
echo"</table>";
echo "<table align=\"center\" width=\"100%\" bgcolor=\"$bg_color2\" cellspacing=\"1\" cellpadding=\"3\" border=\"0\">";
echo"<tr>"
."<td width=\"50%\" bgcolor=\"$bg_color2\" align=\"center\"><font class=\"pn-normal\">"
."<input type=\"hidden\" name=\"profileid\" value=\"$profileid\">"
."<input type=\"hidden\" name=\"user_avatar2\" value=\"$user_avatar\">"
."<input type=\"hidden\" name=\"module\" value=\"".$ModName."\">"
."<input type=\"hidden\" name=\"req\" value=\"DoModifyMember\">"
//."<input type=\"hidden\" name=\"authid\" value=\"" . pnSecGenAuthKey() . "\">"
."<input type=\"submit\" value=\""._SAVECHANGES."\"></form></td>
</tr>";
echo"</table>";
and then show the selected image chosen from the SELECTBOX (and JavaScript function)
<img src=\"images/avatar/$avatar\" name=\"avatar\" alt=\"$file\" align=\"top\">
The JavaScript onChange code
function showimage()
{
if (!document.images)
return
document.images.avatar.src= 'images/avatar/' + document.Register.user_avatar.options[document.Register.user_avatar.selectedIndex].value
}
The dropdown works excellent. The value I need passed is the selected image from the dropdown-box.
Hope You get what I need