...

View Full Version : Javascript help for class



subie4evr
04-21-2008, 10:54 PM
Hi all,
I am trying to do this for a class and something I think is really simple is holding me back. Here is a code snippet:

<% var FeePaid = rs2("FeePaid").value
Response.write(FeePaid);

if (FeePaid == "True")
{
%>
Fee Paid:<input type="checkbox" checked="true" name="fee"/>
<%}

else
{
Response.write(" I'm sorry");
}%>

Basically what I have gathered is that rs2("FeePaid").value is being passed to the page correctly and FeePaid is being assigned correctly. The rs2("FeePaid").value is a True/False (Access checkbox) and I need to show its status on this asp page. What I think is wrong is that the if () is not working correctly. If anyone has any suggestions they would be enormously appreciated. Thanks!

Corey Emmons

mjlorbet
04-21-2008, 11:13 PM
why are you using javascript for a server side language? moreover, what does rs2 return, the htmlelement corresponding to the name/id passed as a parameter (asking because i do not see an object with that name)? moreover, if you're expecting FeePaid to be a boolean value, you'd use if(FeePaid) (or FeePaid==true) to check to see if it is true, if you're expecting it to be converted to a string from a boolean then the value would be "true" not "True" unless you were comparing the strings case-insensitively.

liorean
04-22-2008, 01:09 AM
why are you using javascript for a server side language?Doesn't really matter, does it? The choice of language is superficial in an environment that supports many languages. The fact that some piece of code is ASP, JSP, ASP.NET or SSJS is much more important than whether it's VBScript or JScript; whether it's Java, JRuby, Jython or Rhino; whether it's C#.NET, VB.NET or JScript.NET.

mjlorbet
04-22-2008, 01:13 AM
just curious, thought it was perhaps unintentional

subie4evr
04-22-2008, 03:53 PM
thank you for the reply. I have tried removing the quotes, but to no avail, it then gives me a "'True' is undefined" message. I have also tried changing cases but that did not work either. Thanks for your help so far!

mjlorbet
04-22-2008, 04:13 PM
True with a lower case t, True is not defined, however true = true and true = !false

subie4evr
04-22-2008, 04:22 PM
huh? I'm not sure I understand.

mjlorbet
04-22-2008, 04:24 PM
in your code you've been writing True which should be true. javascript is case sensitive, so when you write True, it's looking for a variable by the name of True, it can't find one so the value is undefined. if you write true, however, it looks for the boolean constant which is identity defined as true

subie4evr
04-22-2008, 04:57 PM
I got it to work finally by using your suggestion. Here is the final code:

<% var FeePaid = !false;

if (rs2("FeePaid").value == FeePaid)
{
%>

<tr>
<td colspan="2"><center>Fee Paid:<input type="checkbox" value="true" checked="checked" name="fee" /></center></td>
</tr>
<%}
else



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum