Results 1 to 5 of 5

Thread: Return False

  1. #1
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10

    Unanswered: Return False

    Yes, I know Java <> Javascript....

    anyway: I have the following function that validates a date based on the component parts sent to it.
    HTML Code:
      function isValidDate(date, month, year)
      {
        var flagDate = new Date(year, month, date);
        
        if (flagDate.getFullYear() != year || flagDate.getMonth() != month || flagDate.getDate() != date)
        {
        //alert("false")
        return false;
        }
        else
        {
        //alert("true")
        return true;
        }
      }
    the problem I have is: The above function is called from another function and the "return false;" & "return true;" lines do not do what I want them to...

    If the above function validates to false, I want to stop the function it was called from from continuing.

    Hope that makes some sort of sense?

    Thanks -GeorgeV
    George
    Home | Blog

  2. #2
    Join Date
    Jan 2005
    Posts
    362

    Variable

    You may return a variable and check that at your main program.
    What exactly do you do? Form example.
    Dimis

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    You know what - I think I've just solved it!

    I decided to set up a flag which got set to "T" or "F" which I could test on when I returned to the first function.

    I had some trouble with declaring variables and setting values in and outside of the function but I think I'm there now!
    Code:
        if (flagDate.getFullYear() != year || flagDate.getMonth() != month || flagDate.getDate() != date)
            {
            Test = "F"
            return Test
            }
    Code:
          if (Test == "T")
          {alert("Test = T")}
    thank you for your suggestion
    George
    Home | Blog

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Ahh, but I have a lovely new JS problem
    Code:
      var x = document.getElementsByName("urn:schemas-microsoft-com:office:office#Training_x0020_Course")[0];
      x.onchange = TrainingCourseOnChange;  
      
      function TrainingCourseOnChange()
      {
        alert("You chose course: " + x.value)
      }
    The above code applies to a drop down listbox which works...
    Except x.value is the ID number of the object in the list, not the text stored next to it! (I've added a screenie for clarification).

    And I want to return the Text as shown in the textbox...

    Yes, I am unfortunate enough to be working with sharepoint for this problem
    Attached Thumbnails Attached Thumbnails DropDown.JPG  
    George
    Home | Blog

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Ok, solved this problem after about 3 hours of googling + pure chance...
    x.option[selecedtIndex].text

    That's if my memory serves correctly!
    Last edited by gvee; 08-09-07 at 10:36.
    George
    Home | Blog

Posting Permissions

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