Created
July 2, 2015 04:16
-
-
Save montycheese/b4c1bd859ee2ca533530 to your computer and use it in GitHub Desktop.
Customer service decision tree in javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
$(document).ready( function () { | |
$('#customerTripsTable').DataTable(); | |
$('#customerNotesTable').DataTable(); | |
} ); | |
//reset all children nodes in tree if the parent is clicked | |
document.getElementById("contacttype").onclick = destroyChildren; | |
//listener for contact type dropdown | |
document.getElementById("contacttype").onchange = function() { | |
var selected = document.getElementById("contacttype").value; | |
if(selected == 'initial'){ | |
//alert(selected); | |
// display another dropdown | |
document.getElementById("initial").style.display ='block'; | |
} | |
else if(selected == 'incoming'){ | |
showNotesField(); | |
} | |
else if(selected == 'outgoing'){ | |
document.getElementById("outgoing").style.display ='block'; | |
showNotesField(); | |
} | |
else if(selected == 'custom'){ | |
showNotesField(); | |
} | |
else{ | |
alert('error'); | |
} | |
} | |
//listener for INITIAL contact dropdown | |
document.getElementById("initial_contact").onchange = function(){ | |
var selected = document.getElementById("initial_contact").value; | |
if(selected == 'vm'){ | |
document.getElementById("how_you_heard").style.display ='none'; | |
removeNotesField(); | |
} | |
else if (selected == 'telephone' || | |
selected == 'email' || | |
selected == 'text') | |
{ | |
document.getElementById("how_you_heard").style.display ='block'; | |
showNotesField(); | |
} | |
} | |
/** | |
* Destroys children nodes if the decision tree is changed | |
*/ | |
function destroyChildren(){ | |
document.getElementById("initial").style.display ='none'; | |
document.getElementById("outgoing").style.display ='none'; | |
document.getElementById("how_you_heard").style.display ='none'; | |
removeNotesField(); | |
} | |
/** | |
* Reveals the contact notes field | |
*/ | |
function showNotesField(){ | |
document.getElementById("notes").style.display ='block'; | |
} | |
/** | |
* Hides the contact notes field | |
*/ | |
function removeNotesField(){ | |
document.getElementById("notes").style.display ='none'; | |
} | |
/** | |
* Ajax request to call process that resets customer password and sends them a new password via email | |
*/ | |
function resetPassword(){ | |
if(confirm('Are you sure you want to reset?')){ | |
$.ajax | |
({ | |
url: 'php/doResetCustomerPassword.php', | |
type: 'post', | |
success: function(data) | |
{ | |
if(data){ | |
alert("Reset!"); | |
} | |
else { | |
alert("Password NOT reset"); | |
} | |
} | |
}); | |
} | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment