If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > JAVA > Return False

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-18-07, 05:17
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
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
Twitter | Blog
Reply With Quote
  #2 (permalink)  
Old 04-18-07, 05:55
dimis2500 dimis2500 is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 04-18-07, 05:59
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
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
Twitter | Blog
Reply With Quote
  #4 (permalink)  
Old 04-18-07, 06:19
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
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
Return False-dropdown.jpg  
__________________
George
Twitter | Blog
Reply With Quote
  #5 (permalink)  
Old 04-18-07, 14:04
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Ok, solved this problem after about 3 hours of googling + pure chance...
x.option[selecedtIndex].text

That's if my memory serves correctly!
__________________
George
Twitter | Blog

Last edited by gvee; 08-09-07 at 09:36.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On