skip to Main Content

I have an online page with a number of icons displayed, in pre-determined columns.
Some of the icons are omitted based on the authority level of the admin person accessing the page. Even if an icon is omitted, I want following icons in the same line to be displayed in the correct columns. An example of what I am trying is (in C):
The code in the else path being intended to cause a blank field to be output to take up the space taken by the "Member History" icon, so that the following icon will be in the same place irrespective of whether the "Member History" icon has been displayed.

fprintf(ouFile, "<td align=center>");
If (Authority > 5)
{
    fprintf(ouFile, "<button class="button1" type=submit name=u049>");
    fprintf(ouFile, "Member History");
    fprintf(ouFile, "</button></td>");
else
{
    fprintf(ouFile, "<"&nbsp;&nbsp;&nbsp;&nbsp;");
    fprintf(ouFile, "</td>");
}
fprintf(ouFile, "<td align=center>");

However, the result is as if I had not inserted the else path. The next icon in the row is shown in the column of the "Member History" icon if it had been included.

What am I doing wrong? How do I achieve what I wanted?

2

Answers


  1. fprintf(ouFile, "<td align=center>");
    if (Authority > 5)
    {
        fprintf(ouFile, "<button class="button1" type="submit" name="u049">");
        fprintf(ouFile, "Member History");
        fprintf(ouFile, "</button></td>");
    }
    else
    {
        fprintf(ouFile, "&nbsp;</td>");
    }
    

    You need to ensure a <td> cell is always rendered, even if it’s empty or contains a placeholder.

    Login or Signup to reply.
  2. I have a whole series of these buttons, each representing a call to an application and called if particular conditions are true. When a button is not needed some of them leave a blank field and others do not. I have solved the problem empirically by putting in an extra <td></td> where necessary, to leave a blank spot for the omitted buttons, so that following buttons in the row end up in the correct column. That worked, but I do not understand why it is sometimes necessary to put in one set and other times to put in two sets. It does not seem to be caused by the cell width.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search