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 6 of 6
  1. #1
    New Coder
    Join Date
    Jun 2012
    Posts
    29
    Thanks
    6
    Thanked 0 Times in 0 Posts

    ajax if then statement help

    I have a joomla module which loads fine howeevr i want to place in a if then statement
    [<script type="text/javascript">
    var d = new Date()
    var time = d.getHours()
    if (time <> 10) then

    "ajaxmoduleloader|position=whoisonline|chrome=xthml|periodical|interval=10000"


    </script>]

    As you see it dont work can anyone make this code work appreciated very much indeed

    Ron

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    Code:
    <script type="text/javascript">
    var d = new Date()
    var time = d.getHours()
    if (time <> 10) then{
    
    ajaxmoduleloader|position=whoisonline|chrome=xthml|periodical|interval=10000
    }
    
    </script>
    perhaps like this, without the qoutes?

  • Users who have thanked DanInMa for this post:

    ronuk99 (09-01-2013)

  • #3
    New Coder
    Join Date
    Jun 2012
    Posts
    29
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Thanks for the reply sorry dont work, unless i remove the if then statement. must be work around. any ideas all appreciated


    ron

  • #4
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,968
    Thanks
    56
    Thanked 557 Times in 554 Posts
    is "then" some specific keyword in joomla? And time <> 10 if it works at all (which as far as I can tell it doesn't) basically means anything that isn't 10.

    If it were straight javascript, it would make more sense to write it this way

    Code:
    <script type="text/javascript">
    var d = new Date()
    var time = d.getHours()
    if (time != 10) {
    // whatever...
    }
    </script>

  • #5
    New Coder
    Join Date
    Jun 2012
    Posts
    29
    Thanks
    6
    Thanked 0 Times in 0 Posts
    yes thanks for the help. basically the ajax is refreshing the info every 30 seconds however we want this to refresh every hour on the hour for our radio program schedules will change at these times so we looked at using the if condition statements and so far dont look possible. maybe someone will come up with a miracle

    ron

  • #6
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,968
    Thanks
    56
    Thanked 557 Times in 554 Posts
    it's very possible. My point is that you can't make up keywords and comparison operators (well, you can, but that would be complete overkill for what you are trying to do).

    If you want it to refresh on the hour and you know that you are getting AJAX results every 30 seconds in a reliable fashion, it would make more sense to do

    Code:
    <script type="text/javascript">
    var d = new Date();
    var time = d.getMinutes();
    if (time < 1) {
    // whatever...
    }
    </script>
    although I would feel more comfortable building in some sort of fallback just in case your ajax results come in late


  •  

    Tags for this Thread

    Posting Permissions

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