Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   selection structure nested within another selection structure (http://www.velocityreviews.com/forums/t928588-selection-structure-nested-within-another-selection-structure.html)

4Ankit@gmail.com 12-07-2006 10:26 AM

selection structure nested within another selection structure
 
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


ASM 12-07-2006 11:47 AM

Re: selection structure nested within another selection structure
 
4Ankit@gmail.com 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


All times are GMT. The time now is 11:03 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.