replace dropdown with radio, if short

This commit is contained in:
Korakot Chaovavanich
2001-05-08 09:34:25 +00:00
parent b5e5688792
commit 6f943e9d3e
2 changed files with 28 additions and 10 deletions

View File

@@ -92,16 +92,31 @@ for($i=0;$i<mysql_num_rows($table_def);$i++)
$set = ereg_replace("\\)$", "", $set);
$set = explode(",", $set);
echo "<td><select name=fields[$field]>\n";
echo "<option value=\"\">\n";
for($j=0; $j<count($set);$j++)
{
echo '<option value="'.substr($set[$j], 1, -1).'"';
if($data == substr($set[$j], 1, -1) || ($data == "" && substr($set[$j], 1, -1) == $row_table_def["Default"]))
echo " selected";
echo ">".htmlspecialchars(substr($set[$j], 1, -1))."\n";
}
echo "</select></td>";
// show dropdown or radio depend on length
if (strlen($row_table_def["Type"]) > 20) {
echo "<td><select name=fields[$field]>\n";
echo "<option value=\"\">\n";
for($j=0; $j<count($set);$j++)
{
echo '<option value="'.substr($set[$j], 1, -1).'"';
if($data == substr($set[$j], 1, -1) || ($data == "" && substr($set[$j], 1, -1) == $row_table_def["Default"]))
echo " selected";
echo ">".htmlspecialchars(substr($set[$j], 1, -1))."\n";
}
echo "</select></td>";
}
else {
echo "<td>\n";
for($j=0; $j<count($set);$j++)
{
echo "<input type=radio name=fields[$field] ";
echo 'value="'.substr($set[$j], 1, -1).'"';
if($data == substr($set[$j], 1, -1) || ($data == "" && substr($set[$j], 1, -1) == $row_table_def["Default"]))
echo " checked";
echo ">".htmlspecialchars(substr($set[$j], 1, -1))."\n";
}
echo "</td>";
}
}
elseif(strstr($row_table_def["Type"], "set"))