// JavaScript Document var saveURL = "http://www2.ku.edu/~jgcp/cgi-bin/inc/save.php" var usersURL = "http://www2.ku.edu/~jgcp/cgi-bin/admin/users/usersEdit.php" var usersListURL = "http://www2.ku.edu/~jgcp/cgi-bin/admin/users/usersList.php" var chkUserIdURL = "http://www2.ku.edu/~jgcp/cgi-bin/inc/check_userid_user.php" // ============================================================================== function saveUser(email) { var msg="" var email = escape(document.getElementById('email').value) if(isEmpty(email)!="" || checkEmail(email)!=""){ msg +=isEmpty(email,"Email is blank") alert(msg) return false } if(document.getElementById('user_id')) var id = document.getElementById('user_id').value else var id="" var f_name = document.getElementById('f_name').value msg += isEmpty(f_name,"First Name can not be blank") var l_name = escape(document.getElementById('l_name').value) msg += isEmpty(l_name,"Last Name can not be blank") var phone = stripPhone(document.getElementById('phone').value) msg += isEmpty(phone,"Phone can not be blank") msg += checkPhone(phone,"Phone number") var address = escape(document.getElementById('address').value) var city = escape(document.getElementById('city').value) var state = escape(document.getElementById('state').value) var zip = escape(document.getElementById('zip').value) msg += isEmpty(zip,"Zip can not be blank") msg += checkZip(zip,"Zip code") if(dob = escape(document.getElementById('dob').value)!='') var dob = escape(document.getElementById('dob').value) else var dob='null' //alert(dob) var occupation = escape(document.getElementById('occupation').value) var vactive = escape(document.getElementById('active').value) if(document.getElementById('training_id')) var training_id = escape(document.getElementById('training_id').value) var type = escape(document.getElementById('type').value) var comments = escape(document.getElementById('comments').value) // var services = escape(document.getElementById('services').value) var contact = escape(document.getElementById('contact').value) //alert(msg) if(msg!=""){ alert(msg) messg("x") return false } var userSave = new ajaxObject(saveURL); userSave.callback = function (responseText, responseStatus){} userSave.update('module=users&id=' + id + '&f_name=' + f_name + '&l_name=' + l_name + '&email=' + email + '&phone=' + phone + '&address=' + address + '&city=' + city + '&state=' + state + '&zip=' + zip + '&dob=' + dob + '&occupation=' + occupation + '&vactive=' + vactive + '&training_id=' + training_id + '&type=' + type + '&comments=' + comments + '&contact=' + contact) setTimeout("messg('Your information has been updated!')",500) setTimeout("messg('x')",6000) } // ============================================================================== function messg(msg){ if(msg=='x' || !msg){ document.getElementById('message').style.display='none' return } document.getElementById('message').style.display='block' document.getElementById('message').innerHTML=msg scroll(10,380) } // ============================================================================== function changePW() { if(document.getElementById('PassWord').style.visibility == 'visible'){ document.getElementById('PassWord').style.visibility = 'hidden' document.getElementById('PassWord').style.display = 'none' } else{ document.getElementById('PassWord').style.visibility = 'visible' document.getElementById('PassWord').style.display = 'block' } document.getElementById('message').innerHTML = "" } // ============================================================================== function savePw(id) { var pw = escape(document.getElementById('fpassword').value) if(document.getElementById('fpassword').value != document.getElementById('repassword').value){ alert('Passwords different!\nPlease try again.') document.getElementById('fpassword').focus() document.getElementById('fpassword').value = "" document.getElementById('repassword').value = "" return false } document.getElementById('fpassword').value = "" document.getElementById('repassword').value = "" document.getElementById('PassWord').style.visibility = 'hidden' document.getElementById('PassWord').style.display = 'none' document.getElementById('message').innerHTML = "Your password has been updated!" var pwSave = new ajaxObject(saveURL); pwSave.callback = function (responseText, responseStatus){} pwSave.update('module=users_pw&id=' + id + '&pw=' + pw) } // ============================================================================== function chkUserId(myForm,f) { var email = escape(document.getElementById('email').value) if(isEmpty(email)!="" || checkEmail(email)!=""){ var msg = isEmpty(email,"Email is blank") alert(msg) return false } if(document.getElementById('user_id')) var id = document.getElementById('user_id').value else var id="" var sciFiFeed = new ajaxObject(chkUserIdURL); // Create object sciFiFeed.callback = function (responseText, responseStatus) { displayFeed(responseText, responseStatus,myForm,f); } sciFiFeed.update('email=' + email + '&id=' + id); } function displayFeed(responseText, responseStatus,myForm,f) { if (responseStatus==200) { if(responseText.match("Invalid")){ alert("This Email already exist. Please try another email!") document.getElementById('email').value='' myForm['email'].focus() return false } } else { alert('Failed to get the feed you requested') } }