How to treat Calendar as Form?












1















I have a web app with a calendar page where users can select days.
I want the selected days to be posted to the server which will then render the next page based on the days.
In order to do this, I need the calendar I created to be treated as a form. How do I do something like this. I initially was using an AJAX request since I could store the selected days info in an array, but the issue is that an AJAX request does not load a new page.
Your input is greatly appreciated!










share|improve this question























  • Please insert your code to your question! Without code it's hard to help you.

    – FZs
    Dec 30 '18 at 9:00











  • Unfortunately I don't have the code available right now, but essentially I have a calendar that is rendered as a <table>. Somehow need to send the selected dates (available in an array) in a form submission.

    – sawmilld
    Jan 3 at 13:13
















1















I have a web app with a calendar page where users can select days.
I want the selected days to be posted to the server which will then render the next page based on the days.
In order to do this, I need the calendar I created to be treated as a form. How do I do something like this. I initially was using an AJAX request since I could store the selected days info in an array, but the issue is that an AJAX request does not load a new page.
Your input is greatly appreciated!










share|improve this question























  • Please insert your code to your question! Without code it's hard to help you.

    – FZs
    Dec 30 '18 at 9:00











  • Unfortunately I don't have the code available right now, but essentially I have a calendar that is rendered as a <table>. Somehow need to send the selected dates (available in an array) in a form submission.

    – sawmilld
    Jan 3 at 13:13














1












1








1








I have a web app with a calendar page where users can select days.
I want the selected days to be posted to the server which will then render the next page based on the days.
In order to do this, I need the calendar I created to be treated as a form. How do I do something like this. I initially was using an AJAX request since I could store the selected days info in an array, but the issue is that an AJAX request does not load a new page.
Your input is greatly appreciated!










share|improve this question














I have a web app with a calendar page where users can select days.
I want the selected days to be posted to the server which will then render the next page based on the days.
In order to do this, I need the calendar I created to be treated as a form. How do I do something like this. I initially was using an AJAX request since I could store the selected days info in an array, but the issue is that an AJAX request does not load a new page.
Your input is greatly appreciated!







javascript html forms






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 30 '18 at 8:42









sawmilldsawmilld

84




84













  • Please insert your code to your question! Without code it's hard to help you.

    – FZs
    Dec 30 '18 at 9:00











  • Unfortunately I don't have the code available right now, but essentially I have a calendar that is rendered as a <table>. Somehow need to send the selected dates (available in an array) in a form submission.

    – sawmilld
    Jan 3 at 13:13



















  • Please insert your code to your question! Without code it's hard to help you.

    – FZs
    Dec 30 '18 at 9:00











  • Unfortunately I don't have the code available right now, but essentially I have a calendar that is rendered as a <table>. Somehow need to send the selected dates (available in an array) in a form submission.

    – sawmilld
    Jan 3 at 13:13

















Please insert your code to your question! Without code it's hard to help you.

– FZs
Dec 30 '18 at 9:00





Please insert your code to your question! Without code it's hard to help you.

– FZs
Dec 30 '18 at 9:00













Unfortunately I don't have the code available right now, but essentially I have a calendar that is rendered as a <table>. Somehow need to send the selected dates (available in an array) in a form submission.

– sawmilld
Jan 3 at 13:13





Unfortunately I don't have the code available right now, but essentially I have a calendar that is rendered as a <table>. Somehow need to send the selected dates (available in an array) in a form submission.

– sawmilld
Jan 3 at 13:13












1 Answer
1






active

oldest

votes


















0

















var url = "https://example.com/methd";
var date = document.getElementById("calendar");
var keyName = "dates";

date.addEventListener("change", function(e) {
var form = document.createElement("form");
form.setAttribute("method", "POST");
form.setAttribute("action", url);
var inputField = document.createElement('input');
inputField.setAttribute("type", "hidden");
inputField.setAttribute("name", keyName);
inputField.setAttribute("value", this.value);
form.appendChild(inputfield);
document.body.appendChild(form);
form.submit();
});

<input type="date" id="calendar" />





reference






share|improve this answer
























  • Oh nice this is pretty dope. So keyName would contain the list of dates?

    – sawmilld
    Jan 3 at 13:12











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%2f53976264%2fhow-to-treat-calendar-as-form%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









0

















var url = "https://example.com/methd";
var date = document.getElementById("calendar");
var keyName = "dates";

date.addEventListener("change", function(e) {
var form = document.createElement("form");
form.setAttribute("method", "POST");
form.setAttribute("action", url);
var inputField = document.createElement('input');
inputField.setAttribute("type", "hidden");
inputField.setAttribute("name", keyName);
inputField.setAttribute("value", this.value);
form.appendChild(inputfield);
document.body.appendChild(form);
form.submit();
});

<input type="date" id="calendar" />





reference






share|improve this answer
























  • Oh nice this is pretty dope. So keyName would contain the list of dates?

    – sawmilld
    Jan 3 at 13:12
















0

















var url = "https://example.com/methd";
var date = document.getElementById("calendar");
var keyName = "dates";

date.addEventListener("change", function(e) {
var form = document.createElement("form");
form.setAttribute("method", "POST");
form.setAttribute("action", url);
var inputField = document.createElement('input');
inputField.setAttribute("type", "hidden");
inputField.setAttribute("name", keyName);
inputField.setAttribute("value", this.value);
form.appendChild(inputfield);
document.body.appendChild(form);
form.submit();
});

<input type="date" id="calendar" />





reference






share|improve this answer
























  • Oh nice this is pretty dope. So keyName would contain the list of dates?

    – sawmilld
    Jan 3 at 13:12














0












0








0










var url = "https://example.com/methd";
var date = document.getElementById("calendar");
var keyName = "dates";

date.addEventListener("change", function(e) {
var form = document.createElement("form");
form.setAttribute("method", "POST");
form.setAttribute("action", url);
var inputField = document.createElement('input');
inputField.setAttribute("type", "hidden");
inputField.setAttribute("name", keyName);
inputField.setAttribute("value", this.value);
form.appendChild(inputfield);
document.body.appendChild(form);
form.submit();
});

<input type="date" id="calendar" />





reference






share|improve this answer
















var url = "https://example.com/methd";
var date = document.getElementById("calendar");
var keyName = "dates";

date.addEventListener("change", function(e) {
var form = document.createElement("form");
form.setAttribute("method", "POST");
form.setAttribute("action", url);
var inputField = document.createElement('input');
inputField.setAttribute("type", "hidden");
inputField.setAttribute("name", keyName);
inputField.setAttribute("value", this.value);
form.appendChild(inputfield);
document.body.appendChild(form);
form.submit();
});

<input type="date" id="calendar" />





reference






var url = "https://example.com/methd";
var date = document.getElementById("calendar");
var keyName = "dates";

date.addEventListener("change", function(e) {
var form = document.createElement("form");
form.setAttribute("method", "POST");
form.setAttribute("action", url);
var inputField = document.createElement('input');
inputField.setAttribute("type", "hidden");
inputField.setAttribute("name", keyName);
inputField.setAttribute("value", this.value);
form.appendChild(inputfield);
document.body.appendChild(form);
form.submit();
});

<input type="date" id="calendar" />





var url = "https://example.com/methd";
var date = document.getElementById("calendar");
var keyName = "dates";

date.addEventListener("change", function(e) {
var form = document.createElement("form");
form.setAttribute("method", "POST");
form.setAttribute("action", url);
var inputField = document.createElement('input');
inputField.setAttribute("type", "hidden");
inputField.setAttribute("name", keyName);
inputField.setAttribute("value", this.value);
form.appendChild(inputfield);
document.body.appendChild(form);
form.submit();
});

<input type="date" id="calendar" />






share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 30 '18 at 14:20









Chirag RChirag R

13




13













  • Oh nice this is pretty dope. So keyName would contain the list of dates?

    – sawmilld
    Jan 3 at 13:12



















  • Oh nice this is pretty dope. So keyName would contain the list of dates?

    – sawmilld
    Jan 3 at 13:12

















Oh nice this is pretty dope. So keyName would contain the list of dates?

– sawmilld
Jan 3 at 13:12





Oh nice this is pretty dope. So keyName would contain the list of dates?

– sawmilld
Jan 3 at 13:12


















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%2f53976264%2fhow-to-treat-calendar-as-form%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







Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas