selection structure nested within another selection structure

Discussion in 'Javascript' started by 4Ankit@gmail.com, Dec 7, 2006.

  1. Guest

    Hey guys i am having some trouble with nesting one selection structure
    within another selection structure. At the moment i am unclear what
    selection structures are and just need a simple example of a selection
    structure within another selection structure. I am supposed to use
    function definitions with parameters to validate a form. my code for
    what i have done so far is as follows(cropped):


    function mainFunction() {
    var dateFormat = (document.dateFormat.date.value + " " +
    document.dateFormat.month.value + ", " +
    document.dateFormat.year.value);
    window.alert("The date is " + dateFormat);}
    return; }

    function checkDate( ) {
    if (0<parseInt(document.dateFormat.date.value) &&
    parseInt(document.dateFormat.date.value)<=31) {
    return true;}
    else {window.alert("Problem with the date");
    return false;} }

    Basically how can i change the above checkDate function in include a
    selection structure nested within another selection
    structure.Eventually i will have another 2 functions which will b used
    to validate the year and month the user enters. Your help would be
    great :)
    Have a nice day
     
    , Dec 7, 2006
    #1
    1. Advertising

  2. ASM Guest

    a écrit :
    > Basically how can i change the above checkDate function in include a
    > selection structure nested within another selection
    > structure.Eventually i will have another 2 functions which will b used
    > to validate the year and month the user enters.


    function checkDate( whatForm ) {
    var v = document.forms[whatForm].date.value
    if (0<=v && parseInt(v)<=31) return true;
    else {
    window.alert("Problem with the date");
    v.focus();
    return false;
    }
    }

    function checkMonth( whatForm ) {
    var v = document.forms[whatForm].month.value
    if (0<=v && parseInt(v)<=12) return true;
    else {
    window.alert("Problem with the month");
    v.focus();
    return false;
    }
    }
    function checkYear( whatForm ) {
    var v = ... etc ...
    }

    function mainFunction( whatForm ) {
    checkDat(whatForm);
    checkMonth(whatForm);
    checkYear(whatForm);
    var dateFormat = (d ... etc ...
    }


    --
    Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    Stephane Moriaux and his (less) old Mac already out of date
     
    ASM, Dec 7, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon Niederberger
    Replies:
    2
    Views:
    16,805
    Christian Kaufhold
    Jan 7, 2005
  2. Andrew Crowe
    Replies:
    1
    Views:
    4,551
    Andrew Crowe
    Sep 13, 2004
  3. Amit_Basnak
    Replies:
    3
    Views:
    842
  4. Ultrus
    Replies:
    3
    Views:
    412
    Stefan Behnel
    Jul 9, 2007
  5. uk00121

    Editing a datagrid nested within another datagrid

    uk00121, Apr 14, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    163
    uk00121
    Apr 19, 2004
Loading...

Share This Page