Click to See Complete Forum and Search --> : WANTED: Advice on Simple ASP Statement


kwilliams
11-14-2003, 09:49 AM
Hello,

I have a page that displays applicants from a DB table named dbo.Employ_Jobs. The value from one field (Application_Date) should be either <NULL>, or contain a date (like 09/18/2003 10:59:42 AM Thu)

If this field is empty, I want to show nothing. But if the field is not empty & it does show a date/time value, I want for there to be a red * displayed. This is what I came up with:

<%
var appdate = (rsAppResults1B.Fields.Item("Application_Date").Value);
if (appdate == ""){
var newdate = "";}
else {
var newdate = "<font color='#FF0000'><b>" + "*" + "</b></font>";
Response.Write(newdate);}
%>

When I add this code to the page, all of the records display the red *, even though only some of them should. I tried changing the == to !=, but that operator doesn't work with this statementfor some reason. I'm not sure why this isn't working, so any & all help is appreciated.

P.S. I would show you an example online, but this page is on our intranet site.

KWilliams

rdoekes
11-15-2003, 02:35 PM
try

var newdate = ((appdate == null) ?
"" :
"<font color='#FF0000'><b>" + "*" + "</b></font>");

Hope this works

yurib
11-16-2003, 01:56 PM
t

yurib
11-16-2003, 01:57 PM
Are you using ASP or JavaScript ?

If ASP the sintax is totaly wrong.

<%
dim appdate = rsAppResults1B("Application_Date")
if appdate<>"" then
newdate=""
else
newdate = "<font color='#FF0000'><b>*</b></font>"
end if
Response.Write(newdate)
%>

slyfox
11-17-2003, 03:39 PM
The original poster is using ASP - JScript...

Dunno if you tried this:


<%
var appdate = (rsAppResults1B.Fields.Item("Application_Date").Value);
if (appdate != ""){
var newdate = "<font color='#FF0000'><b>" + "*" + "</b></font>";
Response.Write(newdate);}
%>

kwilliams
11-18-2003, 08:32 AM
Hi all,

Thanks for all of the great responses. I did actually try your suggestion of:

<%
var appdate = (rsAppResults1B.Fields.Item("Application_Date").Value);
if (appdate == ""){
var newdate = "";}
else {
var newdate = "<font color='#FF0000'><b>" + "*" + "</b></font>";
Response.Write(newdate);}
%>

...but it didn't work. I'm not sure why id didn't, since the syntax seems to be correct. So I tried a solution that uses ASP & Javascript together. Here it is:

<%
var appdate = (rsAppResults1B.Fields.Item("Application_Date").Value);
if (appdate = (rsAppResults1B.Fields.Item("Application_Date").Value)){
%>
<script language="JavaScript">
var newdate = "<font color='#FF0000'><b>" + "*" + "</b></font>";
document.write(newdate);
</script>
<%
}
%>

...and this worked. So I'll keep it this way for now. But I'll always be confused on why thie first suggested solution didn't work. If anyone ever sees an ovbious reason why it didn't, please let me know. Thanks.

KWilliams

slyfox
11-18-2003, 08:52 AM
you don't really have to use javascript with this one...

you can also do it like this:


<%
var appdate = (rsAppResults1B.Fields.Item("Application_Date").Value);
if (appdate = (rsAppResults1B.Fields.Item("Application_Date").Value)){
%>
<font color='#FF0000'><b>*</b></font
<%
}
%>


same thing... it just compliments the size of your page if displaying many records

slyfox
11-18-2003, 08:54 AM
sorry..

<font color='#FF0000'><b>*</b></font>

kwilliams
11-18-2003, 08:55 AM
slyfox,

Thanks for the great suggestion. Sometimes it's simple thingsthat drive us nuts...huh? Anyway, your alternative is much simpler, and works great. Thanks again for all of your help!

KWilliams

slyfox
11-18-2003, 09:17 AM
no problem kwilliams!

I know that feeling... get lots of those and counting.. lol:D