Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

datetime-local save

Hi,

How do I save the date and time to the database with datetime-local? (Free format)

<input type="datetime-local" id="myLocalDate" value="2014-06-01T10:55:33">
<input type="hidden" id="webtim1_t" name="webtim1_t" value="">


<script>
function myFunction() {
    var x = document.getElementById("myLocalDate").value;
    document.write(x.form.id);
    }
</script>
asked Jan 26 by grace_yang
Hi paul,
Sorry, I don't understand the code; But you need the Sawtooth software.Not saved to a variable in webtim1_t.

Initially I would like to use this line, "<input type="datetime-local" id=" [% QuestionName() %]_datetimepicker" value="2020-07-01T10:55:33">", to show a simple interface for people to input date and time by themselves. And I would like to save the date and time interviewees enter to a variable,“webtim1_t”. How should I write the code?

The code is as follows:
<input type="datetime-local" id="[% QuestionName() %]_datetimepicker" value="2020-12-01T10:55:39">
<input type="hidden" id="[% QuestionName() %]_t" value="">
<script>
$('#[% QuestionName() %]_t').val($('#[% QuestionName() %]_datepicker').val());
</script>

The test link:
http://r6d.cn/acMkV

Please help me.Thank you.
You say you want an interface for selecting date and time.  Is there a JavaScript tool you have seen that you want to use for this interface?  Have you already added it to the page?
Hi Zachary,
  Yes, I have added it to the page, but I still cannot save it to the database. Please help me.

The code is as follows:
<input type="datetime-local" id="[% QuestionName() %]_datetimepicker" value="2020-12-01T10:55:39">
<input type="hidden" id="[% QuestionName() %]_t" value="">
<script>
$('#[% QuestionName() %]_t').val($('#[% QuestionName() %]_datepicker').val());
</script>

The test link:
http://r6d.cn/acMkV

Thank you.
Your URL does not work for me.  Can you provide a working URL or share your study files with our support team?
Hi Zachary,

I need to save the date and time entered by the interviewee.
URL:
http://online.hyconresearch.com/proj1/cgi-bin/ciwweb.pl?hid_studyname=2020P348t

Thank you very much.

2 Answers

0 votes
Glad that solves the problem.

Well done.
answered Jan 26 by Paul Moon Platinum (87,315 points)
24Hi Paul,
    Sorry, I can't save it to webtim_1, I need date and time written by the respondent.
0 votes
If you haven't already, you'll need to give your free format question a variable named "t."

I believe you need to define the name attribute as well as the ID, like this:

<input type="hidden" id="webtim1_t" name="webtim1_1" value="">


Your script refers to "_datepicker," but the HTML element has "_datetimepicker."
answered Jan 29 by Zachary Platinum Sawtooth Software, Inc. (164,025 points)
...