Script to concatenate date and time into a hidden field

I am trying to use a script that concatenates a date field and a time field.

page1: Has the form that posts to page2.

page1 has a start date and start time as well as an end date and end time. It should put date and time together into a hidden field and then post the data.  In this demo I post it to page 2 but it will ultimately be inserted into a database.

Attached is the code for both pages. Any help is appreciated. As of now the values come up blank.
example.txt
LVL 1
AleksAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
>> var d = document.form1.endtime
>> var drop = d.options[d.selectedIndex];
>> <input type="text" class="form-control" value="11:34" name="endtime"  id="endtime">
d.options applies to <select> elements.  You probably have a plugin that simulates a dropdown view.    Try:
function putDateInHiddenFieldend() {
   var text = document.form1.endate;
   var hidden = document.form1.endatecomp;
   var d = document.form1.endtime;
//   var drop = d.options[d.selectedIndex];  get rid of this
   hidden.value = "";
   hidden.value += text.value + " " + d.value;//use d.value
  }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AleksAuthor Commented:
I used your script but still comes up blank. they are just fields, you can check the code I attached. no drop down menus.
0
AleksAuthor Commented:
I see ... in the previous page I used a drop down for the  'starttime', on this page its a simple text field.
0
AleksAuthor Commented:
I did this and it works now  :)

  <script language="javascript" type="text/javascript">
 <!--
 function putDateInHiddenField() {
  var text = document.form1.startdate;
  var hidden = document.form1.startdatecomp;
  var d = document.form1.startime;
  hidden.value = "";
  hidden.value += text.value + " " + d.value;
 }
 -->
 </script>

Thanks !
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.