jaysprout wrote:Getting the radio [i]buttons where they should be and not looking sloppy would be totally sweet.
<tr><td colspan=2><div class="%s">%s</div>
<tr><td><div class="%s">%s</div><td>
case "radio":
$output[$attr["id"]] .= sprintf("\n".'<tr><td><div class="%s">%s</div><td class="attributeinput">',$attr["required"] ? 'required' : 'attributename',stripslashes($attr["name"]));
case "radio":
$output[$attr["id"]] .= sprintf("\n".'<tr><td><div class="%s">%s</div><td class="attributeinput">',$attr["required"] ? 'required' : 'attributename',stripslashes($attr["name"]));
$values_request = Sql_Query("select * from $table_prefix"."listattr_".$attr["tablename"]." order by listorder,name");
while ($value = Sql_Fetch_array($values_request)) {
if (!empty($_POST[$fieldname]))
$checked = $_POST[$fieldname] == $value["id"] ? 'checked="checked"':'';
else if ($data[$attr["id"]])
$checked = $data[$attr["id"]] == $value["id"] ? 'checked="checked"':'';
else
$checked = $attr["default_value"] == $value["name"] ? 'checked="checked"':'';
$output[$attr["id"]] .= sprintf('<input type="radio" class="attributeinput" name="%s" value="%s" %s /> %s ',
$fieldname,$value["id"],$checked, $value["name"]);
}
if ($attr["required"])
$output[$attr["id"]] .= sprintf('<script language="Javascript" type="text/javascript">addGroupToCheck("%s","%s");</script>',$fieldname,$attr["name"]);
break;
case "checkboxgroup":
$output[$attr["id"]] .= sprintf("\n".'<tr><td><div class="%s">%s</div><td class="attributeinput">',$attr["required"] ? 'required' : 'attributename',stripslashes($attr["name"]));
$values_request = Sql_Query("select * from $table_prefix"."listattr_".$attr["tablename"]." order by listorder,name");
while ($value = Sql_Fetch_array($values_request)) {
$selected = '';
if (is_array($_POST[$fieldname])) {
$selected = in_array($value["id"],$_POST[$fieldname]) ? "checked" : "";
} elseif ($data[$attr["id"]]) {
$selection = explode(",",$data[$attr["id"]]);
$selected = in_array($value["id"],$selection) ? 'checked="checked"':'';
}
$output[$attr["id"]] .= sprintf('<input type="checkbox" name="%s[]" class="attributeinput" value="%s" %s /> %s ',
$fieldname, $value["id"], $selected, stripslashes( $value["name"]) );
}
$output[$attr["id"]] .= sprintf('</td></tr>');
break;
Return to Answers, Howtos, Tips & Tricks
Users browsing this forum: No registered users and 7 guests