Problem with script

I have a script that works in one page but not another. It takes the values of two fields (Date and time) and on click concatenates them into a hidden field before the form is submitted.

Here is my script code:

<!--
 function putDateInHiddenField() {
  var text = document.form1.startdate;
  var hidden = document.form1.startdatecomp;
  var d = document.form1.startime;
  var drop = d.options[d.selectedIndex];
  hidden.value = "";
  hidden.value += text.value + " " + drop.value;
 }
 -->
 </script>
  <script language="javascript" type="text/javascript">
 <!--
 function putDateInHiddenFieldend() {
  var text = document.form1.endate;
  var hidden = document.form1.endatecomp;
  var d = document.form1.endtime;
  var drop = d.options[d.selectedIndex];
  hidden.value = "";
  hidden.value += text.value + " " + drop.value;
 }
 -->
 </script>

This are my hidden fields

<input name="startdatecomp" type="hidden" id="startdatecomp">
              <input name="endatecomp" type="hidden" id="endatecomp">

And this is the button on my form

<button class="btn btn-primary" type="submit" onClick="putDateInHiddenField();putDateInHiddenFieldend();return document.MM_returnValue" >Add</button>

I checked twice and made sure the names of the form and the other fields are correct.  Maybe you can see something I am missing. The scripts work fine on other pages.
LVL 1
AleksAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

dejaanbuCommented:
what is the pbm r u getting? not concatenating the values?
are you getting any JS errors in the console ? check in firefox's developer tools ->web console  for ex.

did  u check by putting an alert for all the values to find the error?
if u have a demo page or something, pls provide the link
AleksAuthor Commented:
Its inside an intranet. Ill try to replicate this on an external page and provide with the link.
Julian HansenCommented:
document.MM_returnValue

Open in new window

The above indicates there are other components at play - can you give us any information on those?

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
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

AleksAuthor Commented:
Ill setup the page outside later tonight. And remove all other things that are not necessary for the purpose of checking this functionality.
AleksAuthor Commented:
Sorry for the delay. Here is what I have. 2 pages.

page1: Has the form that posts to page2. It 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.

Here is code for page1:

---

<!doctype html>
<html>
<head>
</head>

<body>
<form action="test2.asp" method="POST" name="form1" class="form-horizontal" id="form1">

<div class="form-group">
                              <div class="hr-line-dashed"></div>
                           <div class="form-group">
                                          <label class="col-sm-2 control-label">Start date</label>
                                    <div class="form-group" id="data_1">
                               
                                <div class="input-group date">
                                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span><input type="text" class="form-control" value="01/01/2015" name="startdate"  id="startdate">
                                </div>
                            </div>
                              </div>
                              <div class="hr-line-dashed"></div>
                     <div class="form-group">
                                          <label class="col-sm-2 control-label">Start time</label>
                                    <div class="input-group clockpicker" data-autoclose="true">
                                <input type="text" class="form-control" value="09:30" name="startime"  id="startime" >
                                <span class="input-group-addon">
                                    <span class="fa fa-clock-o"></span>
                                </span>
                            </div>
                                        </div>
                              <div class="hr-line-dashed"></div>
                                <div class="form-group">
                                          <label class="col-sm-2 control-label">End date</label>
                                     <div class="form-group" id="data_1">
                               
                                <div class="input-group date">
                                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span><input type="text" class="form-control" value="01/01/2016" name="endate"  id="endate">
                                </div>
                            </div>
                              </div>
                              <div class="hr-line-dashed"></div>
                      <div class="form-group">
                                          <label class="col-sm-2 control-label">End time</label>
                                    <div class="input-group clockpicker" data-autoclose="true">
                                <input type="text" class="form-control" value="11:34" name="endtime"  id="endtime">
                                <span class="input-group-addon">
                                    <span class="fa fa-clock-o"></span>
                                </span>
                        </div>
                      </div>
                              
                              <div class="form-group">
                              <div class="col-sm-4 col-sm-offset-2">
                                    <button class="btn btn-primary" type="submit" onClick="putDateInHiddenField();putDateInHiddenFieldend();return document.MM_returnValue"  >Add</button>
                                
                              </div>
                        </div>
               
                <input type="hidden" name="MM_insert" value="form1" />
                <input name="startdatecomp" type="hidden" id="startdatecomp">
              <input name="endatecomp" type="hidden" id="endatecomp">

                  </form>
</body>
</html>


---

This is code for page 2 . As of now it shows nothing.

<!doctype html>
<html>
<head>
</head>

<body>
<p>start datetime: <%=Request("startdatecomp")%></p>
<p>end date time: <%=Request("endatecomp")%></p>
</body>
</html>
AleksAuthor Commented:
I apologize. page 1 also has the script between the head tags:

  <script language="javascript" type="text/javascript">
 <!--
 function putDateInHiddenField() {
  var text = document.form1.startdate;
  var hidden = document.form1.startdatecomp;
  var d = document.form1.startime;
  var drop = d.options[d.selectedIndex];
  hidden.value = "";
  hidden.value += text.value + " " + drop.value;
 }
 -->
 </script>
  <script language="javascript" type="text/javascript">
 <!--
 function putDateInHiddenFieldend() {
  var text = document.form1.endate;
  var hidden = document.form1.endatecomp;
  var d = document.form1.endtime;
  var drop = d.options[d.selectedIndex];
  hidden.value = "";
  hidden.value += text.value + " " + drop.value;
 }
 -->
 </script>
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.