Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript help for class

    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
    Last edited by subie4evr; 04-21-2008 at 11:56 PM. Reason: email for replies

  • #2
    Regular Coder mjlorbet's Avatar
    Join Date
    Jan 2008
    Location
    Milwaukee, WI
    Posts
    724
    Thanks
    8
    Thanked 96 Times in 95 Posts
    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.
    -Mike
    "Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender

  • #3
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Quote Originally Posted by mjlorbet View Post
    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.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #4
    Regular Coder mjlorbet's Avatar
    Join Date
    Jan 2008
    Location
    Milwaukee, WI
    Posts
    724
    Thanks
    8
    Thanked 96 Times in 95 Posts
    just curious, thought it was perhaps unintentional
    -Mike
    "Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender

  • #5
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!

  • #6
    Regular Coder mjlorbet's Avatar
    Join Date
    Jan 2008
    Location
    Milwaukee, WI
    Posts
    724
    Thanks
    8
    Thanked 96 Times in 95 Posts
    True with a lower case t, True is not defined, however true = true and true = !false
    -Mike
    "Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender

  • #7
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    huh? I'm not sure I understand.

  • #8
    Regular Coder mjlorbet's Avatar
    Join Date
    Jan 2008
    Location
    Milwaukee, WI
    Posts
    724
    Thanks
    8
    Thanked 96 Times in 95 Posts
    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
    -Mike
    "Want me to precludify him, like some kind of dispatcherator?... Can do!" -Bender

  • #9
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •