admin管理员组文章数量:1337159
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, "\<\"\ \ \ \ \");
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?
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, "\<\"\ \ \ \ \");
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?
Share Improve this question edited Jan 8 at 0:50 WarwickW 455 bronze badges asked Jan 6 at 9:51 WarwickWrWarwickWr 6 | Show 1 more comment2 Answers
Reset to default 0fprintf(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, " </td>");
}
You need to ensure a <td>
cell is always rendered, even if it's empty or contains a placeholder.
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.
本文标签:
版权声明:本文标题:HTML: How do I display an icon in the correct place when an icon to the left is optionally omitted: - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743283475a2493508.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
fprintf()
in the Else path has three double quotes ("
) on it, making the quotes unterminated. Was that just a typo in your post, or is that error in the original too? And when posting scripts or program code, please use the editing tools to apply code formatting (the{}
button in the question/answer editing toolbar) to it, so the site won't re-wrap the lines and indentation works as appropriate for code. – telcoM Commented Jan 6 at 10:43<
in theelse
clause, as you are not supplying a tag? Also remove the superfluous quote adjacent to it – Vercingatorix Commented Jan 6 at 15:38<fprintf
supposed to be? – Barmar Commented Jan 6 at 23:30<
and&
? Were those added automatically by the Stacks Editor? – Barmar Commented Jan 6 at 23:31else
block makes no sense. You have<
with no matching>
. There's no tag name, just a bunch of
. – Barmar Commented Jan 6 at 23:35