how to display text in condition to a form or database value

 

note: this sample is just to give you ideas of where to look at. to make more advanced tasks work consult your VBScript or JavaScript reference.

if you use the data bindings panel to drag items to the page you will get code like the following

<%= Request("vtext") %>

or

<%=(Recordset1.Fields.Item("vtext").Value)%>

this will simply output the value of that item as text. but sometimes you want to display other text depending on this value.

lets assume you want to print "Hi there!" if the value is "x" but "Hello there!" in any other case.

here is how to do it.

VBScript:

<%
If (Request("vtext") = "x") then
  Response.Write("Hi there!")
Else
  Response.Write("Hello there!")
End if
%>

or

<%
If (Recordset1.Fields.Item("vtext").Value = "x") then
  Response.Write("Hi there!")
Else
  Response.Write("Hello there!")
End if
%>

JavaScript:

<%
var bgx_val = String(Request("vtext"));
if (bgx_val == "x") {
  Response.Write("Hi there!");
  }
else {
  Response.Write("Hello there!");
  }
%>

or

<%
var bgx_val = String(Recordset1.Fields.Item("vtext").Value);
if (bgx_val == "x") {
  Response.Write("Hi there!");
  }
else {
  Response.Write("Hello there!");
  }
%>

 

 


 

1