IF..ELSE in HTML

  • Thread starter Thread starter Rick
  • Start date Start date
R

Rick

What is wrong with the following code? the code print both data (FALSE and
TRUE)

<tr>
<!--[if [[$MyBooleanDataField]] = false ]>
<td class="data">FALSE</td>
<!-- [Elseif [[$MyBooleanDataField]] = true ]>
<td class="data">TRUE</td>
<![endif]-->
</tr>
 
HTML is a Markup Language, not a programming language, so has no logic
structures.

If you are developing in .Net, however, you can embed inline scripting on
the page:

<% If (1 = 1) Then%>
True
<% Else%>
False
<% End If%>

The <% %> tags are where your actual code will go.

Hope that helps!

William
 
I've put your logic in to my code below but it still does not work and give
me both Yes and No; I need it to print either Yes or No.

Yes No
Did you need help?

************** code start ***************
<!-- [[ BeginContext $MyData[] ]] -->
<table>
<tr>
<td nowrap>Did you need help?</td>
<% If ([[$MyBooleanHelpFlag]] = 1) Then%>
Yes
<% Else%>
No
<% End If%>
</tr>
</table>
<!-- [[ EndContext ]] -->
************** code end ***************



William Niver said:
HTML is a Markup Language, not a programming language, so has no logic
structures.

If you are developing in .Net, however, you can embed inline scripting on
the page:

<% If (1 = 1) Then%>
True
<% Else%>
False
<% End If%>

The <% %> tags are where your actual code will go.

Hope that helps!

William

Rick said:
What is wrong with the following code? the code print both data (FALSE
and
TRUE)

<tr>
<!--[if [[$MyBooleanDataField]] = false ]>
<td class="data">FALSE</td>
<!-- [Elseif [[$MyBooleanDataField]] = true ]>
<td class="data">TRUE</td>
<![endif]-->
</tr>
 
Rick said:
************** code start ***************
<!-- [[ BeginContext $MyData[] ]] -->
<table>
<tr>
<td nowrap>Did you need help?</td>
<% If ([[$MyBooleanHelpFlag]] = 1) Then%>
Yes
<% Else%>
No
<% End If%>
</tr>
</table>
<!-- [[ EndContext ]] -->
************** code end ***************

Rick, I think you're getting your languages mixed up. This is an ASP.NET
forum. Your <!-- [[ BeginContext $MyData[] ]] --> certainly does not look
like ASP.NET, you need to post in an appropriate forum for the technology
you are developing in.

Pete
 
Pete,
It is HTML; is there a newgroup to support html or what's the approperiate
newsgroup for htnl related questions?

Pete Hurst said:
Rick said:
************** code start ***************
<!-- [[ BeginContext $MyData[] ]] -->
<table>
<tr>
<td nowrap>Did you need help?</td>
<% If ([[$MyBooleanHelpFlag]] = 1) Then%>
Yes
<% Else%>
No
<% End If%>
</tr>
</table>
<!-- [[ EndContext ]] -->
************** code end ***************

Rick, I think you're getting your languages mixed up. This is an ASP.NET
forum. Your <!-- [[ BeginContext $MyData[] ]] --> certainly does not look
like ASP.NET, you need to post in an appropriate forum for the technology
you are developing in.

Pete
 
I've put your logic in to my code below but it still does not work and
give
me both Yes and No; I need it to print either Yes or No.
************** code start ***************
<!-- [[ BeginContext $MyData[] ]] -->
<table>
<tr>
<td nowrap>Did you need help?</td>
<% If ([[$MyBooleanHelpFlag]] = 1) Then%>
Yes
<% Else%>
No
<% End If%>
</tr>
</table>
<!-- [[ EndContext ]] -->
************** code end ***************

Of course it's going to give you yes AND no. You've routed your
logic around regular text which will always be output. Try..

<%
If (something = 1) Then
Response.Write("yes")
Else
Response.Write("no")
End If
%>

John
 
Back
Top