@@ -841,7 +841,7 @@ $(document).on("click", "#last", function(){
// Add new data in sheet
$(document).on("click", "#add-new", function(){
- for (let i = 0; i < 20; i++) {
+ for (let i = 0; i < 22; i++) {
newValue.push($(`#new${i}`).val())
}
// add data in googlesheet using ajax
@@ -850,27 +850,15 @@ $(document).on("click", "#add-new", function(){
url: ''+ window.location.origin +'/gsheet/api/addRow',
data: { data : newValue },
success: function(response) {
- if (response.status == 200 && response.statusCode == 1) {
- // Get the first form with the name
- // Usually the form name is not repeated
- // but duplicate names are possible in HTML
- // Therefore to work around the issue, enforce the correct index
+ if (response.statusCode == 1) {
var frm = document.getElementsByName('contact-form')[0];
- frm.submit(); // Submit the form
frm.reset(); // Reset all form data
- return false; // Prevent page refresh
alert("Data added successfully");
window.location.reload()
}
- else if(response.status == 200 && response.statusCode == 0){
- // Get the first form with the name
- // Usually the form name is not repeated
- // but duplicate names are possible in HTML
- // Therefore to work around the issue, enforce the correct index
+ else{
var frm = document.getElementsByName('contact-form')[0];
- frm.submit(); // Submit the form
frm.reset(); // Reset all form data
- return false; // Prevent page refresh
alert("Data added successfully");
window.location.reload()
}