0

当前输出为一个长列表

$output .= "<div class=\"selector\">\n";
$output .= "<form method=\"post\">\n";
if ($type == "new") {
    $output .= "<input type=\"hidden\" name=\"type\" value=\"new\">\n";
    $output .= getPhaseDD("phase", $phase) . " &nbsp; ";
    $output .= "Day:" . getDayDD($day) . " &nbsp; ";
    $output .= "Number:" . getNumDD($num) . " ";
} else {
    $output .= "<input type=\"hidden\" name=\"type\" value=\"existing\">\n";
    $output .= "<input type=\"hidden\" name=\"phase\" value=\"{$phase}\">\n";
    $output .= "<input type=\"hidden\" name=\"day\" value=\"{$day}\">\n";
    $output .= "<input type=\"hidden\" name=\"num\" value=\"{$num}\">\n";
    $output .= "<div>Phase: {$phase}, Day: {$day}, Number: {$num}</div>";
}
if ($type == "new") {
    $output .= "<div><textarea name=\"msg\" rows=\"8\" cols=\"50\" id=\"msg\"   onkeyup=\"javascript:countTXT(this, 'cnt', 160);\" onkeydown=\"javascript:countTXT(this, 'cnt', 160);\">" . stripslashes($msg) . "</textarea></div>\n";
    $output .= "<div id=\"cnt\"></div>\n";
} else {
    $output .= "<div><textarea name=\"msg\" id=\"msg_{$day}_{$num}\" onkeyup=\"javascript:countTXT(this, 'cnt_{$day}_{$num}', 160);\" onkeydown=\"javascript:countTXT(this, 'cnt_{$day}_{$num}', 160);\">" . stripslashes($msg) . "</textarea></div>\n";
    $output .= "<div id=\"cnt_{$day}_{$num}\"></div>\n";
}
$output .= "<div>\n";
if ($type == "new") {
    $output .= "<input type=\"submit\" name=\"create_btn\" value=\"Create\" class=\"create_btn\">\n";
} else {
    $output .= "<input type=\"submit\" name=\"update_btn\" value=\"Update\" class=\"update_btn\"> \n";
    $output .= "<input type=\"submit\" name=\"delete_btn\" value=\"Delete\" class=\"delete_btn\" onclick=\"javascript:return confirmDelete();\">\n";
}
$output .= "</div>\n";
$output .= "</form>\n";
$output .= "</div>\n";
if ($type == "new") {
    $output .= "<script type=\"text/javascript\">countTXT(document.getElementById('msg'), 'cnt', 160);</script>\n";
} else {
    $output .= "<script type=\"text/javascript\">countTXT(document.getElementById('msg_{$day}_{$num}'), 'cnt_{$day}_{$num}', 160);</script>\n";
}
return $output;

我想在两列中显示,因为显示了很多消息,而且它会比一个长滚动条更干净。

4

2 回答 2

0

你可以做两个div,一个float:left,另一个float:right。如果这不是动态生成的(似乎不是),那么您可以对 HTML 进行硬编码。我错过了什么吗?

于 2013-04-12T19:48:11.847 回答
0

看起来您发布的代码是在一个循环中创建的,x 次。一种方法是将第一半包裹在 a<div style="float:left">中,第二半包裹在 a<div style="float:right">或 plain<div>中。

例如。

// start the left float div
echo "<div style=\"float:left; padding:50px;\">";

// # of total divs in the 2 columns
$x = 12;

// for loop, change
for($i=1;$i<=$x;$i++){

// if we have reached the halfway mark, close the left float div and create the right side
if($i==(($x/2)+1)) {echo "</div><div style=\"padding:50px;\">";}

// this is where your div loop goes
echo "<div>Phase: Pre-Quit, Day: 1, Number:{$i}<br /><textarea cols=\"30\">Message {$i}</textarea></div>";}

// close the right div
echo "</div>";

你可以在 - http://phpfiddle.org/main/code/9be-ax8看到这个例子

在此处输入图像描述

于 2013-04-12T21:01:08.883 回答