Jquery Datepicker in multiple fields and saving the inputs












0















I'm still learning and my newest project got me stuck on this:



Inside of a table to manage customers, I want to have an input field with a datepicker (https://longbill.github.io/jquery-date-range-picker/ using this) for every row, like this:



<td>
//some more content
<div class="includeDatepicker">
<input type="text" class="datepicker">
</div>
</td>


the whole thing gets set up like this:



jQuery("document").ready(function () {
jQuery('.datepicker').dateRangePicker({
autoClose: true,
singleDate : true,
showShortcuts: false,
singleMonth: true,
startOfWeek: 'monday',
separator : ' ~ ',
format: 'DD.MM.YYYY HH:mm',
time: {
enabled: true
}
});
});


Until here, it works fine. Then though:




  1. The datepicker only appears for the first input field in the first row of the table and will appear only there even if the others are clicked. What can I do to add a datepicker to every input field? I'm already using a class selector. I have done my research on this and found some solutions, but I can't really wrap my head around it either way.


  2. How would it be possible that the date written to the input fields is saved even when the page is refreshed?



I would greatly appreciate any help and I've done research before asking on here, but none of it was to great avail.



Greetings










share|improve this question




















  • 1





    Have you tried adding an id attribute to the <td> ? Add some logic so as to ensure that each <td> has an id and then try it. I think that ids are required on the <td>

    – mkane
    Nov 23 '18 at 12:04











  • Thank you! But shouldn't they have different IDs then? How would I do that since I'm only listing them once?

    – Clopin Trouillefou
    Nov 23 '18 at 12:09






  • 1





    Yes in html each id on the elements should be unique. It depend on how you are building up the table contents. If it entered by hand then just assign each td a unique id i.e. <td id="includeDatepicker1"> , <td id="includeDatepicker2"> etc.. etc..

    – mkane
    Nov 23 '18 at 12:16











  • The table is build by looping through the customers.

    – Clopin Trouillefou
    Nov 23 '18 at 12:18






  • 1





    Sorry just looking at it again and jQuery('.datepicker').dateRangePicker( ... assigns to each input in the table based on the class. You would need some kind of id on the text input though for when submitting the data so you know what entity you are saving.

    – mkane
    Nov 23 '18 at 12:54
















0















I'm still learning and my newest project got me stuck on this:



Inside of a table to manage customers, I want to have an input field with a datepicker (https://longbill.github.io/jquery-date-range-picker/ using this) for every row, like this:



<td>
//some more content
<div class="includeDatepicker">
<input type="text" class="datepicker">
</div>
</td>


the whole thing gets set up like this:



jQuery("document").ready(function () {
jQuery('.datepicker').dateRangePicker({
autoClose: true,
singleDate : true,
showShortcuts: false,
singleMonth: true,
startOfWeek: 'monday',
separator : ' ~ ',
format: 'DD.MM.YYYY HH:mm',
time: {
enabled: true
}
});
});


Until here, it works fine. Then though:




  1. The datepicker only appears for the first input field in the first row of the table and will appear only there even if the others are clicked. What can I do to add a datepicker to every input field? I'm already using a class selector. I have done my research on this and found some solutions, but I can't really wrap my head around it either way.


  2. How would it be possible that the date written to the input fields is saved even when the page is refreshed?



I would greatly appreciate any help and I've done research before asking on here, but none of it was to great avail.



Greetings










share|improve this question




















  • 1





    Have you tried adding an id attribute to the <td> ? Add some logic so as to ensure that each <td> has an id and then try it. I think that ids are required on the <td>

    – mkane
    Nov 23 '18 at 12:04











  • Thank you! But shouldn't they have different IDs then? How would I do that since I'm only listing them once?

    – Clopin Trouillefou
    Nov 23 '18 at 12:09






  • 1





    Yes in html each id on the elements should be unique. It depend on how you are building up the table contents. If it entered by hand then just assign each td a unique id i.e. <td id="includeDatepicker1"> , <td id="includeDatepicker2"> etc.. etc..

    – mkane
    Nov 23 '18 at 12:16











  • The table is build by looping through the customers.

    – Clopin Trouillefou
    Nov 23 '18 at 12:18






  • 1





    Sorry just looking at it again and jQuery('.datepicker').dateRangePicker( ... assigns to each input in the table based on the class. You would need some kind of id on the text input though for when submitting the data so you know what entity you are saving.

    – mkane
    Nov 23 '18 at 12:54














0












0








0








I'm still learning and my newest project got me stuck on this:



Inside of a table to manage customers, I want to have an input field with a datepicker (https://longbill.github.io/jquery-date-range-picker/ using this) for every row, like this:



<td>
//some more content
<div class="includeDatepicker">
<input type="text" class="datepicker">
</div>
</td>


the whole thing gets set up like this:



jQuery("document").ready(function () {
jQuery('.datepicker').dateRangePicker({
autoClose: true,
singleDate : true,
showShortcuts: false,
singleMonth: true,
startOfWeek: 'monday',
separator : ' ~ ',
format: 'DD.MM.YYYY HH:mm',
time: {
enabled: true
}
});
});


Until here, it works fine. Then though:




  1. The datepicker only appears for the first input field in the first row of the table and will appear only there even if the others are clicked. What can I do to add a datepicker to every input field? I'm already using a class selector. I have done my research on this and found some solutions, but I can't really wrap my head around it either way.


  2. How would it be possible that the date written to the input fields is saved even when the page is refreshed?



I would greatly appreciate any help and I've done research before asking on here, but none of it was to great avail.



Greetings










share|improve this question
















I'm still learning and my newest project got me stuck on this:



Inside of a table to manage customers, I want to have an input field with a datepicker (https://longbill.github.io/jquery-date-range-picker/ using this) for every row, like this:



<td>
//some more content
<div class="includeDatepicker">
<input type="text" class="datepicker">
</div>
</td>


the whole thing gets set up like this:



jQuery("document").ready(function () {
jQuery('.datepicker').dateRangePicker({
autoClose: true,
singleDate : true,
showShortcuts: false,
singleMonth: true,
startOfWeek: 'monday',
separator : ' ~ ',
format: 'DD.MM.YYYY HH:mm',
time: {
enabled: true
}
});
});


Until here, it works fine. Then though:




  1. The datepicker only appears for the first input field in the first row of the table and will appear only there even if the others are clicked. What can I do to add a datepicker to every input field? I'm already using a class selector. I have done my research on this and found some solutions, but I can't really wrap my head around it either way.


  2. How would it be possible that the date written to the input fields is saved even when the page is refreshed?



I would greatly appreciate any help and I've done research before asking on here, but none of it was to great avail.



Greetings







jquery input datepicker submit






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 11:50







Clopin Trouillefou

















asked Nov 23 '18 at 11:41









Clopin TrouillefouClopin Trouillefou

155




155








  • 1





    Have you tried adding an id attribute to the <td> ? Add some logic so as to ensure that each <td> has an id and then try it. I think that ids are required on the <td>

    – mkane
    Nov 23 '18 at 12:04











  • Thank you! But shouldn't they have different IDs then? How would I do that since I'm only listing them once?

    – Clopin Trouillefou
    Nov 23 '18 at 12:09






  • 1





    Yes in html each id on the elements should be unique. It depend on how you are building up the table contents. If it entered by hand then just assign each td a unique id i.e. <td id="includeDatepicker1"> , <td id="includeDatepicker2"> etc.. etc..

    – mkane
    Nov 23 '18 at 12:16











  • The table is build by looping through the customers.

    – Clopin Trouillefou
    Nov 23 '18 at 12:18






  • 1





    Sorry just looking at it again and jQuery('.datepicker').dateRangePicker( ... assigns to each input in the table based on the class. You would need some kind of id on the text input though for when submitting the data so you know what entity you are saving.

    – mkane
    Nov 23 '18 at 12:54














  • 1





    Have you tried adding an id attribute to the <td> ? Add some logic so as to ensure that each <td> has an id and then try it. I think that ids are required on the <td>

    – mkane
    Nov 23 '18 at 12:04











  • Thank you! But shouldn't they have different IDs then? How would I do that since I'm only listing them once?

    – Clopin Trouillefou
    Nov 23 '18 at 12:09






  • 1





    Yes in html each id on the elements should be unique. It depend on how you are building up the table contents. If it entered by hand then just assign each td a unique id i.e. <td id="includeDatepicker1"> , <td id="includeDatepicker2"> etc.. etc..

    – mkane
    Nov 23 '18 at 12:16











  • The table is build by looping through the customers.

    – Clopin Trouillefou
    Nov 23 '18 at 12:18






  • 1





    Sorry just looking at it again and jQuery('.datepicker').dateRangePicker( ... assigns to each input in the table based on the class. You would need some kind of id on the text input though for when submitting the data so you know what entity you are saving.

    – mkane
    Nov 23 '18 at 12:54








1




1





Have you tried adding an id attribute to the <td> ? Add some logic so as to ensure that each <td> has an id and then try it. I think that ids are required on the <td>

– mkane
Nov 23 '18 at 12:04





Have you tried adding an id attribute to the <td> ? Add some logic so as to ensure that each <td> has an id and then try it. I think that ids are required on the <td>

– mkane
Nov 23 '18 at 12:04













Thank you! But shouldn't they have different IDs then? How would I do that since I'm only listing them once?

– Clopin Trouillefou
Nov 23 '18 at 12:09





Thank you! But shouldn't they have different IDs then? How would I do that since I'm only listing them once?

– Clopin Trouillefou
Nov 23 '18 at 12:09




1




1





Yes in html each id on the elements should be unique. It depend on how you are building up the table contents. If it entered by hand then just assign each td a unique id i.e. <td id="includeDatepicker1"> , <td id="includeDatepicker2"> etc.. etc..

– mkane
Nov 23 '18 at 12:16





Yes in html each id on the elements should be unique. It depend on how you are building up the table contents. If it entered by hand then just assign each td a unique id i.e. <td id="includeDatepicker1"> , <td id="includeDatepicker2"> etc.. etc..

– mkane
Nov 23 '18 at 12:16













The table is build by looping through the customers.

– Clopin Trouillefou
Nov 23 '18 at 12:18





The table is build by looping through the customers.

– Clopin Trouillefou
Nov 23 '18 at 12:18




1




1





Sorry just looking at it again and jQuery('.datepicker').dateRangePicker( ... assigns to each input in the table based on the class. You would need some kind of id on the text input though for when submitting the data so you know what entity you are saving.

– mkane
Nov 23 '18 at 12:54





Sorry just looking at it again and jQuery('.datepicker').dateRangePicker( ... assigns to each input in the table based on the class. You would need some kind of id on the text input though for when submitting the data so you know what entity you are saving.

– mkane
Nov 23 '18 at 12:54












1 Answer
1






active

oldest

votes


















1














I think for 2nd part an approach like this :



jQuery("document").ready(function () {
jQuery('.datepicker').dateRangePicker({
autoClose: true,
singleDate : true,
showShortcuts: false,
singleMonth: true,
startOfWeek: 'monday',
separator : ' ~ ',
format: 'DD.MM.YYYY HH:mm',
time: {
enabled: true
}
},function(start, end, label) {
console.log(start.format('YYYY-MM-DD') + ' TO: ' + end.format('YYYY-MM-DD'));
}
);
});


Inside that function above you could then make an AJAX call to the DB but as I said earlier you will need some id on the element so you can pass it back to the service layer so as to ensure you know what entity they are updating....



Im am not sure what date range picker you are using but if the one I think then plenty of examples @ http://www.daterangepicker.com/#options



Add a new functions something like :



function updateDBWithVals(urlToServer,startDateFromFrontEnd,endDateFromFrontEnd,rowID) {    
return $.ajax({
url: urlToServer,
data: {startDate : startDateFromFrontEnd, endDate: endDateFromFrontEnd, entityID: rowID},
type: "POST",
success: function(response) {
console.log(response);
},
error: function(error) {
console.log(error);
}
});
}


Now in your call back function just call it i.e.



function(start, end, label) {
console.log(start.format('YYYY-MM-DD') + ' TO: ' + end.format('YYYY-MM-DD'));
updateDBWithVals("urlToYourServerLogic",start.format('YYYY-MM-DD'),end.format('YYYY-MM-DD'),"theIDOfTheRow");
}





share|improve this answer


























  • I don't know how to set different IDs or how to call them for the elements later on and I can't find anything for that searching on Google. What I did made them change on every page load which doesn't really achieve anything. I have only this one line (<input type="text" class="datepicker">) as the entire table is called in a loop to create a row for every customer.

    – Clopin Trouillefou
    Nov 23 '18 at 15:40











  • Still, thank you for your help, I just feel pretty stupid lol.

    – Clopin Trouillefou
    Nov 23 '18 at 15:40











  • If each row on the table is for a customer then you could apply a html id attribute to that row as part of the table creation. The id could just be the primary key of the customer from the DB or something that would allow you to do a lookup and update their data in the DB. In the function then when it is called you could use JQuery to grab the parent row html ID and pass it to the AJAX call .. Don't give up everything is achievable. Maybe put what you have so far into a JSFiddle and we can take it from there...

    – mkane
    Nov 23 '18 at 15:57













  • Can I marry you or at least honor you a thousand times on here? Just kidding, could you give me an example of how that call could look like? I managed to do the ID thing now.

    – Clopin Trouillefou
    Nov 23 '18 at 16:03












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53446045%2fjquery-datepicker-in-multiple-fields-and-saving-the-inputs%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














I think for 2nd part an approach like this :



jQuery("document").ready(function () {
jQuery('.datepicker').dateRangePicker({
autoClose: true,
singleDate : true,
showShortcuts: false,
singleMonth: true,
startOfWeek: 'monday',
separator : ' ~ ',
format: 'DD.MM.YYYY HH:mm',
time: {
enabled: true
}
},function(start, end, label) {
console.log(start.format('YYYY-MM-DD') + ' TO: ' + end.format('YYYY-MM-DD'));
}
);
});


Inside that function above you could then make an AJAX call to the DB but as I said earlier you will need some id on the element so you can pass it back to the service layer so as to ensure you know what entity they are updating....



Im am not sure what date range picker you are using but if the one I think then plenty of examples @ http://www.daterangepicker.com/#options



Add a new functions something like :



function updateDBWithVals(urlToServer,startDateFromFrontEnd,endDateFromFrontEnd,rowID) {    
return $.ajax({
url: urlToServer,
data: {startDate : startDateFromFrontEnd, endDate: endDateFromFrontEnd, entityID: rowID},
type: "POST",
success: function(response) {
console.log(response);
},
error: function(error) {
console.log(error);
}
});
}


Now in your call back function just call it i.e.



function(start, end, label) {
console.log(start.format('YYYY-MM-DD') + ' TO: ' + end.format('YYYY-MM-DD'));
updateDBWithVals("urlToYourServerLogic",start.format('YYYY-MM-DD'),end.format('YYYY-MM-DD'),"theIDOfTheRow");
}





share|improve this answer


























  • I don't know how to set different IDs or how to call them for the elements later on and I can't find anything for that searching on Google. What I did made them change on every page load which doesn't really achieve anything. I have only this one line (<input type="text" class="datepicker">) as the entire table is called in a loop to create a row for every customer.

    – Clopin Trouillefou
    Nov 23 '18 at 15:40











  • Still, thank you for your help, I just feel pretty stupid lol.

    – Clopin Trouillefou
    Nov 23 '18 at 15:40











  • If each row on the table is for a customer then you could apply a html id attribute to that row as part of the table creation. The id could just be the primary key of the customer from the DB or something that would allow you to do a lookup and update their data in the DB. In the function then when it is called you could use JQuery to grab the parent row html ID and pass it to the AJAX call .. Don't give up everything is achievable. Maybe put what you have so far into a JSFiddle and we can take it from there...

    – mkane
    Nov 23 '18 at 15:57













  • Can I marry you or at least honor you a thousand times on here? Just kidding, could you give me an example of how that call could look like? I managed to do the ID thing now.

    – Clopin Trouillefou
    Nov 23 '18 at 16:03
















1














I think for 2nd part an approach like this :



jQuery("document").ready(function () {
jQuery('.datepicker').dateRangePicker({
autoClose: true,
singleDate : true,
showShortcuts: false,
singleMonth: true,
startOfWeek: 'monday',
separator : ' ~ ',
format: 'DD.MM.YYYY HH:mm',
time: {
enabled: true
}
},function(start, end, label) {
console.log(start.format('YYYY-MM-DD') + ' TO: ' + end.format('YYYY-MM-DD'));
}
);
});


Inside that function above you could then make an AJAX call to the DB but as I said earlier you will need some id on the element so you can pass it back to the service layer so as to ensure you know what entity they are updating....



Im am not sure what date range picker you are using but if the one I think then plenty of examples @ http://www.daterangepicker.com/#options



Add a new functions something like :



function updateDBWithVals(urlToServer,startDateFromFrontEnd,endDateFromFrontEnd,rowID) {    
return $.ajax({
url: urlToServer,
data: {startDate : startDateFromFrontEnd, endDate: endDateFromFrontEnd, entityID: rowID},
type: "POST",
success: function(response) {
console.log(response);
},
error: function(error) {
console.log(error);
}
});
}


Now in your call back function just call it i.e.



function(start, end, label) {
console.log(start.format('YYYY-MM-DD') + ' TO: ' + end.format('YYYY-MM-DD'));
updateDBWithVals("urlToYourServerLogic",start.format('YYYY-MM-DD'),end.format('YYYY-MM-DD'),"theIDOfTheRow");
}





share|improve this answer


























  • I don't know how to set different IDs or how to call them for the elements later on and I can't find anything for that searching on Google. What I did made them change on every page load which doesn't really achieve anything. I have only this one line (<input type="text" class="datepicker">) as the entire table is called in a loop to create a row for every customer.

    – Clopin Trouillefou
    Nov 23 '18 at 15:40











  • Still, thank you for your help, I just feel pretty stupid lol.

    – Clopin Trouillefou
    Nov 23 '18 at 15:40











  • If each row on the table is for a customer then you could apply a html id attribute to that row as part of the table creation. The id could just be the primary key of the customer from the DB or something that would allow you to do a lookup and update their data in the DB. In the function then when it is called you could use JQuery to grab the parent row html ID and pass it to the AJAX call .. Don't give up everything is achievable. Maybe put what you have so far into a JSFiddle and we can take it from there...

    – mkane
    Nov 23 '18 at 15:57













  • Can I marry you or at least honor you a thousand times on here? Just kidding, could you give me an example of how that call could look like? I managed to do the ID thing now.

    – Clopin Trouillefou
    Nov 23 '18 at 16:03














1












1








1







I think for 2nd part an approach like this :



jQuery("document").ready(function () {
jQuery('.datepicker').dateRangePicker({
autoClose: true,
singleDate : true,
showShortcuts: false,
singleMonth: true,
startOfWeek: 'monday',
separator : ' ~ ',
format: 'DD.MM.YYYY HH:mm',
time: {
enabled: true
}
},function(start, end, label) {
console.log(start.format('YYYY-MM-DD') + ' TO: ' + end.format('YYYY-MM-DD'));
}
);
});


Inside that function above you could then make an AJAX call to the DB but as I said earlier you will need some id on the element so you can pass it back to the service layer so as to ensure you know what entity they are updating....



Im am not sure what date range picker you are using but if the one I think then plenty of examples @ http://www.daterangepicker.com/#options



Add a new functions something like :



function updateDBWithVals(urlToServer,startDateFromFrontEnd,endDateFromFrontEnd,rowID) {    
return $.ajax({
url: urlToServer,
data: {startDate : startDateFromFrontEnd, endDate: endDateFromFrontEnd, entityID: rowID},
type: "POST",
success: function(response) {
console.log(response);
},
error: function(error) {
console.log(error);
}
});
}


Now in your call back function just call it i.e.



function(start, end, label) {
console.log(start.format('YYYY-MM-DD') + ' TO: ' + end.format('YYYY-MM-DD'));
updateDBWithVals("urlToYourServerLogic",start.format('YYYY-MM-DD'),end.format('YYYY-MM-DD'),"theIDOfTheRow");
}





share|improve this answer















I think for 2nd part an approach like this :



jQuery("document").ready(function () {
jQuery('.datepicker').dateRangePicker({
autoClose: true,
singleDate : true,
showShortcuts: false,
singleMonth: true,
startOfWeek: 'monday',
separator : ' ~ ',
format: 'DD.MM.YYYY HH:mm',
time: {
enabled: true
}
},function(start, end, label) {
console.log(start.format('YYYY-MM-DD') + ' TO: ' + end.format('YYYY-MM-DD'));
}
);
});


Inside that function above you could then make an AJAX call to the DB but as I said earlier you will need some id on the element so you can pass it back to the service layer so as to ensure you know what entity they are updating....



Im am not sure what date range picker you are using but if the one I think then plenty of examples @ http://www.daterangepicker.com/#options



Add a new functions something like :



function updateDBWithVals(urlToServer,startDateFromFrontEnd,endDateFromFrontEnd,rowID) {    
return $.ajax({
url: urlToServer,
data: {startDate : startDateFromFrontEnd, endDate: endDateFromFrontEnd, entityID: rowID},
type: "POST",
success: function(response) {
console.log(response);
},
error: function(error) {
console.log(error);
}
});
}


Now in your call back function just call it i.e.



function(start, end, label) {
console.log(start.format('YYYY-MM-DD') + ' TO: ' + end.format('YYYY-MM-DD'));
updateDBWithVals("urlToYourServerLogic",start.format('YYYY-MM-DD'),end.format('YYYY-MM-DD'),"theIDOfTheRow");
}






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 23 '18 at 17:31

























answered Nov 23 '18 at 14:36









mkanemkane

29949




29949













  • I don't know how to set different IDs or how to call them for the elements later on and I can't find anything for that searching on Google. What I did made them change on every page load which doesn't really achieve anything. I have only this one line (<input type="text" class="datepicker">) as the entire table is called in a loop to create a row for every customer.

    – Clopin Trouillefou
    Nov 23 '18 at 15:40











  • Still, thank you for your help, I just feel pretty stupid lol.

    – Clopin Trouillefou
    Nov 23 '18 at 15:40











  • If each row on the table is for a customer then you could apply a html id attribute to that row as part of the table creation. The id could just be the primary key of the customer from the DB or something that would allow you to do a lookup and update their data in the DB. In the function then when it is called you could use JQuery to grab the parent row html ID and pass it to the AJAX call .. Don't give up everything is achievable. Maybe put what you have so far into a JSFiddle and we can take it from there...

    – mkane
    Nov 23 '18 at 15:57













  • Can I marry you or at least honor you a thousand times on here? Just kidding, could you give me an example of how that call could look like? I managed to do the ID thing now.

    – Clopin Trouillefou
    Nov 23 '18 at 16:03



















  • I don't know how to set different IDs or how to call them for the elements later on and I can't find anything for that searching on Google. What I did made them change on every page load which doesn't really achieve anything. I have only this one line (<input type="text" class="datepicker">) as the entire table is called in a loop to create a row for every customer.

    – Clopin Trouillefou
    Nov 23 '18 at 15:40











  • Still, thank you for your help, I just feel pretty stupid lol.

    – Clopin Trouillefou
    Nov 23 '18 at 15:40











  • If each row on the table is for a customer then you could apply a html id attribute to that row as part of the table creation. The id could just be the primary key of the customer from the DB or something that would allow you to do a lookup and update their data in the DB. In the function then when it is called you could use JQuery to grab the parent row html ID and pass it to the AJAX call .. Don't give up everything is achievable. Maybe put what you have so far into a JSFiddle and we can take it from there...

    – mkane
    Nov 23 '18 at 15:57













  • Can I marry you or at least honor you a thousand times on here? Just kidding, could you give me an example of how that call could look like? I managed to do the ID thing now.

    – Clopin Trouillefou
    Nov 23 '18 at 16:03

















I don't know how to set different IDs or how to call them for the elements later on and I can't find anything for that searching on Google. What I did made them change on every page load which doesn't really achieve anything. I have only this one line (<input type="text" class="datepicker">) as the entire table is called in a loop to create a row for every customer.

– Clopin Trouillefou
Nov 23 '18 at 15:40





I don't know how to set different IDs or how to call them for the elements later on and I can't find anything for that searching on Google. What I did made them change on every page load which doesn't really achieve anything. I have only this one line (<input type="text" class="datepicker">) as the entire table is called in a loop to create a row for every customer.

– Clopin Trouillefou
Nov 23 '18 at 15:40













Still, thank you for your help, I just feel pretty stupid lol.

– Clopin Trouillefou
Nov 23 '18 at 15:40





Still, thank you for your help, I just feel pretty stupid lol.

– Clopin Trouillefou
Nov 23 '18 at 15:40













If each row on the table is for a customer then you could apply a html id attribute to that row as part of the table creation. The id could just be the primary key of the customer from the DB or something that would allow you to do a lookup and update their data in the DB. In the function then when it is called you could use JQuery to grab the parent row html ID and pass it to the AJAX call .. Don't give up everything is achievable. Maybe put what you have so far into a JSFiddle and we can take it from there...

– mkane
Nov 23 '18 at 15:57







If each row on the table is for a customer then you could apply a html id attribute to that row as part of the table creation. The id could just be the primary key of the customer from the DB or something that would allow you to do a lookup and update their data in the DB. In the function then when it is called you could use JQuery to grab the parent row html ID and pass it to the AJAX call .. Don't give up everything is achievable. Maybe put what you have so far into a JSFiddle and we can take it from there...

– mkane
Nov 23 '18 at 15:57















Can I marry you or at least honor you a thousand times on here? Just kidding, could you give me an example of how that call could look like? I managed to do the ID thing now.

– Clopin Trouillefou
Nov 23 '18 at 16:03





Can I marry you or at least honor you a thousand times on here? Just kidding, could you give me an example of how that call could look like? I managed to do the ID thing now.

– Clopin Trouillefou
Nov 23 '18 at 16:03




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53446045%2fjquery-datepicker-in-multiple-fields-and-saving-the-inputs%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini