2013-02-16 65 views
0
​​

表格高度?

correct display

的錯誤顯示首先顯示。請注意這些行與其餘的行不一致。當筆記長於一行時,我希望消息循環並且其他兩個表的高度相同,以便數據正確顯示。

我在這裏看到一個JavaScript解決方案,但它似乎並沒有在我的代碼中工作。雖然看起來並不一樣。也許我只是錯誤地實現了它。其中之一會很好,因爲我不想製作一些真正複雜的CSS文件或任何東西。

謝謝!

這是我的unphp'd表代碼。

<table class="detail_status"> 
<tr> 
    <th>Status History</th> 
    <th>Outstanding Hours</th> 
    <th>User Notes</th> 
</tr> 
<tr> 
    <td> 
     <form action="..." method=post> 
      <select name="change_status"> 
       <option value="unset">Change Status</option><option value="New">New</option><option value="Remote Actions Completed">Remote Actions Completed</option><option value="On-Site Actions Completed">On-Site Actions Completed</option><option value="Company Tech Dispatched">Company Tech Dispatched</option><option value="Tech On Site">Tech On Site</option> </select> 
       <input type="submit" name="change_status_button" value="Change"> 
     </form> 
    </td> 
    <td>&nbsp;</td> <!-- Yeah I know. I'm going to fix the CSS later. --> 
    <td> 
     <form method="post" action="..."> 
      <input type="submit" name="edit_notes" value="Edit Recent Note"> 
     </form> 
    </td> 
</tr> 
<tr> 
    <td class="status_1"> 
     <table class="tabInTab"> 
      <tr class="added"><td><b>Fixed by Contractor<b></td></tr> <tr><td>Tech On Site</td></tr> <tr><td>Remote Actions Completed</td></tr> <tr><td>Company Tech Dispatched8</td></tr> 
      </table> 
    </td> 
    <td class="status_2"> 
     <table class="tabInTab"> 
      <tr><td>1 hrs 17 mins</td></tr> <tr><td>1 hrs 18 mins</td></tr> <tr><td>21 hrs 48 mins</td></tr> <tr><td>21 hrs 49 mins</td></tr> 
      </table> 
    </td> 
    <td class="status_3"> 
     <table class="tabInTab"> 
       <tr><td>Long textLong textLong textLong textLong textLong textLong textLong textLong textLong textLong textLong text</td></tr><tr><td>None</td></tr><tr><td>None</td></tr><tr><td>None</td></tr> 
      </table> 
    </td> 
</tr> 

echo '<table class="detail_status"> 
           <tr> 
            <th>Status History</th> 
            <th>Outstanding Hours</th> 
            <th>User Notes</th> 
           </tr>'; 
          if($row['resolution'] == '') { 
         echo '<tr> 
            <td> 
             <form action="'.$_SERVER['REQUEST_URI'].'" method=post> 
              <select name="change_status"> 
               <option value="unset">Change Status</option>'; 
               $status_list = "SELECT status FROM current_status"; 
               $result_status = mysqli_query($db, $status_list); 
               while($stat = mysqli_fetch_array($result_status)) { 
                $status = $stat['status']; 
                echo "<option value=\"$status\">$status</option>"; 
               } 
               echo' </select> 
               <input type="submit" name="change_status_button" value="Change"> 
             </form> 
            </td> 
            <td>&nbsp;</td>'; 
            if(!isset($_POST['edit_notes'])) { 
             echo' <td><form method="post" action="'.$_SERVER['REQUEST_URI'].'"> 
                <input type="submit" name="edit_notes" value="Edit Recent Note"> 
                </form> 
               </td>'; 
            } 
            else { 
             echo' <td><form method="post" action="'.$_SERVER['REQUEST_URI'].'"> 
                <input type="submit" name="save_notes" value="Save Note">          
               </td>'; 
            } 
           echo '</tr>'; 
          }      
         if($statusPrev1 != '' && $statusPrev2 != '' && $statusPrev3 != '') { 
          $dispCount = 3; 
         } 
         else if($statusPrev1 != '' && $statusPrev2 != '') { 
          $dispCount = 2; 
         } 
         else if($statusPrev1 != '') { 
          $dispCount = 1; 
         } 
         else { //No status set 
          $dispCount = 0; 
         } 
         echo '<tr> 
            <td class="status_1"> 
             <table class="tabInTab"> 
              <tr class="added"><td><b>'.$currStatus.'<b></td></tr>'; 
              for($x=1;$x<=$dispCount;$x++) { 
               echo' <tr><td>'.getPrevious('status', $previous, $x).'</td></tr>'; 
              } 
           echo' </table> 
            </td> 
            <td class="status_2"> 
             <table class="tabInTab"> 
              <tr><td>'.calcHoursOutstanding($status_timestamp).'</td></tr>'; 
              for($x=1;$x<=$dispCount;$x++) { 
               echo' <tr><td>'.calcHoursOutstanding(getPrevious('time', $previous, $x)).'</td></tr>'; 
              } 
           echo '</table> 
            </td> 
            <td class="status_3"> 
             <table class="tabInTab">'; 
              if(!isset($_POST['edit_notes'])) { 
               echo '<tr><td>'.$notes.'</td></tr>'; 
               for($x=1;$x<=$dispCount;$x++) { 
                echo '<tr><td>'.getPrevious('notes', $previous, $x).'</td></tr>'; 
               } 
              } 
              else { 
                if(isset($_POST['note_text'])) { //Probably Unneccesary? 
                 echo '<input type="textbox" name="note_text" value="'.$_POST['note_text'].'">'; 
                } 
                else { 
                 echo '<input type="textbox" name="note_text" value="'.$notes.'">'; 
                } 
                //End of Save note form. Have to end it here to have the note_text be POSTed 
                echo '</form>';           
               //Started index at 2 to skip first one which is displayed above.  
               for($x=1;$x<=$dispCount;$x++) { 
                echo' <tr><td>'.getPrevious('notes', $previous, $x).'</td></tr>'; 
               } 
              } 
           echo '</table> 
            </td> 
           </tr> 
          </table>'; 
+0

我不明白這和PHP有什麼關係...... – 2013-02-16 03:18:20

+0

我的歉意。我只是添加了PHP代碼。我忘了這是必要的,大聲笑 – jakecraige 2013-02-16 03:58:31

+0

我不認爲這是。我認爲你做了正確的事情,把它抽象出來並給我們HTML,但是我認爲應該刪除[tag:php]標籤。 – 2013-02-16 11:23:46

回答

1

你不應該嵌套表,你是這樣的。您需要確保表中的每一行都有三個單元格。你這樣做的方式,你可以讓各個表獨立增長,而不會相互依賴。

見我上的jsfiddle:http://jsfiddle.net/vzBrF/

這是你的行應該是什麼樣子:

<tr> 
    <td class="status_1">Fixed by Contractor</td> 
    <td>1 hrs 17 mins</td> 
    <td>Long textLong textLong textLong textLong textLong textLong textLong textLong textLong textLong textLong tex</td> 
</tr> 
+0

我想這就是我的php進來的地方,哈。它循環訪問數組,爲表單分別提取特定的數據。雖然我可能剛剛提出了一個解決方案 – jakecraige 2013-02-16 03:57:09

0

好消息:我想通了感謝傑夫的提醒,以保持它的簡單。我想,當我把信息的邏輯輸入到信息的邏輯之前,我想到了一種特定的方式。 不好的消息:我現在甚至想問這個問題,我覺得自己很傻。

echo '<tr> 
     <td class="status_1 added"><b>'.$currStatus.'<b></td> 
     <td>'.calcHoursOutstanding($status_timestamp).'</td> 
     <td>'; 
     if(!isset($_POST['edit_notes'])) { 
      echo $notes;            
     } 
     else { 
      if(isset($_POST['note_text'])) { //Probably Unneccesary? 
       echo '<input type="textbox" name="note_text" value="'.$_POST['note_text'].'">'; 
      } 
      else { 
       echo '<input type="textbox" name="note_text" value="'.$notes.'">'; 
      } 
      //End of Save note form. Have to end it here to have the note_text be POSTed 
      echo '</form>';  
     } 
     echo' </td> 
    </tr>'; ///End current info row 
    for($x=1;$x<=$dispCount;$x++) { 
     echo '<tr> 
       <td class="status_1">'.getPrevious('status', $previous, $x).'</td> 
       <td class="status_2">'.calcHoursOutstanding(getPrevious('time', $previous, $x)).'</td> 
       <td class="status_3">'.getPrevious('notes', $previous, $x).'</td> 
       </tr>'; 
    } 
+0

很高興我能幫上忙。如果我的回答回答了您的問題,那麼StackOverflow上的正確迴應是「接受」它(單擊複選標記)。 – Jeff 2013-02-16 15:09:37