IF..ELSE in HTML

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>
 
W

William Niver

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
 
R

Rick

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>
 
P

Pete Hurst

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
 
R

Rick

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
 
J

JM

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,130
Latest member
MitchellTe
Top