function windowThere(theURL,winName,features) { if (top.opener && !top.opener.closed) { top.opener.location.href = theURL; } else { if (window.winName) { //change href of {winName} winName.location.href = theURL; } else { PopWin(theURL,winName,features); } } } /* heres the href to use... test */ // submit the form to the specified page function goToPage( pageUrl ) { // the form object that will be used var form_object = document.kidsform; validation_success = validate_form( form_object ); if ( validation_success ) { form_object.action = pageUrl; form_object.submit(); } else { window.alert( 'Sorry, you did not complete the form correctly' ); } } function PopWin( theURL, winName, features ) { window.open( theURL, winName, features ); } function PopW(theURL,winName,features) { window.close(); window.open(theURL,winName,features); } // required_elements contains the names of elements that have to be // filled in before the form can be submitted required_elements = new Array(); // check_format_elements contains the names and formats of elements // that have to be filled in with the correct format before // the form can be submitted check_format_elements = new Array(); // add an element to the required_elements array function add_required_element( element_name ) { required_elements[ required_elements.length ] = element_name; } // add an element to the check_format_elements array function add_check_format_element( element_name, element_format ) { element_to_format = new Array( element_name, element_format ) check_format_elements[ check_format_elements.length ] = element_to_format; } /** * returns true if all the required elements are filled in and all * the formated elements have the right format. otherwise returns false. */ function validate_form() { var form_is_valid = true; for ( i = 0; i < required_elements.length; i++ ) { elements = document.getElementsByName( required_elements[ i ] ); if (getRadio(required_elements[i])){ //alert('k'); } else { var form_is_valid = false; } } return form_is_valid; } /** * returns true if the required element is filled in, false otherwise */ function validate_required_element(name, type, format) { // TODO: implement //alert(name + ', ' + type + ', ' + format); return true; } /** * returns true if the formatted element is filled in with the correct * format, false otherwise. * note: it will return true if the element * is not filled in at all. this is so that optional elements can be * tested for formatting. */ function validate_formatted_element() { // TODO: implement return true; } function saveResult() { goToPage( 'save_to_myplan.php' ); } function getRadio(grpName) { var grp, rad, r = 0; grp = (typeof grpName == 'string') ? document.kidsform[grpName] : grpName; while (rad = grp[r++]) if (rad.checked) return rad.value; return ''; }