Move js code from html page to js file and call that code in my html page












-1















Hi guys i am trying to move my js code from my phtml page to js page and i would like to call to that page in to my phtml page. And i am working in zend.



Can anyone help me how can i do that.



here is my phtml code:



   <div class="reminderForm">
<form id="reminderForm_<?php echo $this->ticketId;?>">
<h4><?php echo $this->translate('set_reminder'); ?></h4>
<span class="formz-required">*</span>
<?php echo $this->form->remark;?>
<?php if ($this->isAllowed('ticket.index.reminder-type')) : ?>
<span class="remark-element-span formz-required">*</span>
<?php echo $this->form->reminderType;
endif; ?>
<span class="remark-element-span formz-required">*</span>
<?php
echo $this->form->reopenTicket;
echo $this->form->ticketId;
?>
<div class="button-block">
<span><?php echo $this->form->cancel; ?></span>
<span><?php echo $this->form->save; ?></span>
</div>
</form>
</div>
<?php
echo $this->inlineScript()->appendScript(<<<EOS
$(".reopenTicket").datetimepicker({
showOn: "button",
buttonImage: "/themes/bas/icons/fatcow/16x16/calendar.png",
dateFormat:'dd-mm-yy',
timeFormat: 'HH:mm',
buttonImageOnly: true,
controlType: 'select',
showWeek: true,
firstDay: 1,
oneLine : true
});
var today = new Date();
var tomorrow = new Date();
tomorrow.setDate(today.getDate()+1);
tomorrow.setHours(8);
tomorrow.setMinutes(0);
$(".reopenTicket").datetimepicker("setDate", new Date(tomorrow));
EOS
);
?>


And here is my js file :



    var REMINDER = {};

REMINDER.Followupreminder = {

};


inside that



 REMINDER.Followupreminder = {

};


function i would like to call that js code.



Can anyone help me how can i do that.
Thanks in advance.










share|improve this question



























    -1















    Hi guys i am trying to move my js code from my phtml page to js page and i would like to call to that page in to my phtml page. And i am working in zend.



    Can anyone help me how can i do that.



    here is my phtml code:



       <div class="reminderForm">
    <form id="reminderForm_<?php echo $this->ticketId;?>">
    <h4><?php echo $this->translate('set_reminder'); ?></h4>
    <span class="formz-required">*</span>
    <?php echo $this->form->remark;?>
    <?php if ($this->isAllowed('ticket.index.reminder-type')) : ?>
    <span class="remark-element-span formz-required">*</span>
    <?php echo $this->form->reminderType;
    endif; ?>
    <span class="remark-element-span formz-required">*</span>
    <?php
    echo $this->form->reopenTicket;
    echo $this->form->ticketId;
    ?>
    <div class="button-block">
    <span><?php echo $this->form->cancel; ?></span>
    <span><?php echo $this->form->save; ?></span>
    </div>
    </form>
    </div>
    <?php
    echo $this->inlineScript()->appendScript(<<<EOS
    $(".reopenTicket").datetimepicker({
    showOn: "button",
    buttonImage: "/themes/bas/icons/fatcow/16x16/calendar.png",
    dateFormat:'dd-mm-yy',
    timeFormat: 'HH:mm',
    buttonImageOnly: true,
    controlType: 'select',
    showWeek: true,
    firstDay: 1,
    oneLine : true
    });
    var today = new Date();
    var tomorrow = new Date();
    tomorrow.setDate(today.getDate()+1);
    tomorrow.setHours(8);
    tomorrow.setMinutes(0);
    $(".reopenTicket").datetimepicker("setDate", new Date(tomorrow));
    EOS
    );
    ?>


    And here is my js file :



        var REMINDER = {};

    REMINDER.Followupreminder = {

    };


    inside that



     REMINDER.Followupreminder = {

    };


    function i would like to call that js code.



    Can anyone help me how can i do that.
    Thanks in advance.










    share|improve this question

























      -1












      -1








      -1








      Hi guys i am trying to move my js code from my phtml page to js page and i would like to call to that page in to my phtml page. And i am working in zend.



      Can anyone help me how can i do that.



      here is my phtml code:



         <div class="reminderForm">
      <form id="reminderForm_<?php echo $this->ticketId;?>">
      <h4><?php echo $this->translate('set_reminder'); ?></h4>
      <span class="formz-required">*</span>
      <?php echo $this->form->remark;?>
      <?php if ($this->isAllowed('ticket.index.reminder-type')) : ?>
      <span class="remark-element-span formz-required">*</span>
      <?php echo $this->form->reminderType;
      endif; ?>
      <span class="remark-element-span formz-required">*</span>
      <?php
      echo $this->form->reopenTicket;
      echo $this->form->ticketId;
      ?>
      <div class="button-block">
      <span><?php echo $this->form->cancel; ?></span>
      <span><?php echo $this->form->save; ?></span>
      </div>
      </form>
      </div>
      <?php
      echo $this->inlineScript()->appendScript(<<<EOS
      $(".reopenTicket").datetimepicker({
      showOn: "button",
      buttonImage: "/themes/bas/icons/fatcow/16x16/calendar.png",
      dateFormat:'dd-mm-yy',
      timeFormat: 'HH:mm',
      buttonImageOnly: true,
      controlType: 'select',
      showWeek: true,
      firstDay: 1,
      oneLine : true
      });
      var today = new Date();
      var tomorrow = new Date();
      tomorrow.setDate(today.getDate()+1);
      tomorrow.setHours(8);
      tomorrow.setMinutes(0);
      $(".reopenTicket").datetimepicker("setDate", new Date(tomorrow));
      EOS
      );
      ?>


      And here is my js file :



          var REMINDER = {};

      REMINDER.Followupreminder = {

      };


      inside that



       REMINDER.Followupreminder = {

      };


      function i would like to call that js code.



      Can anyone help me how can i do that.
      Thanks in advance.










      share|improve this question














      Hi guys i am trying to move my js code from my phtml page to js page and i would like to call to that page in to my phtml page. And i am working in zend.



      Can anyone help me how can i do that.



      here is my phtml code:



         <div class="reminderForm">
      <form id="reminderForm_<?php echo $this->ticketId;?>">
      <h4><?php echo $this->translate('set_reminder'); ?></h4>
      <span class="formz-required">*</span>
      <?php echo $this->form->remark;?>
      <?php if ($this->isAllowed('ticket.index.reminder-type')) : ?>
      <span class="remark-element-span formz-required">*</span>
      <?php echo $this->form->reminderType;
      endif; ?>
      <span class="remark-element-span formz-required">*</span>
      <?php
      echo $this->form->reopenTicket;
      echo $this->form->ticketId;
      ?>
      <div class="button-block">
      <span><?php echo $this->form->cancel; ?></span>
      <span><?php echo $this->form->save; ?></span>
      </div>
      </form>
      </div>
      <?php
      echo $this->inlineScript()->appendScript(<<<EOS
      $(".reopenTicket").datetimepicker({
      showOn: "button",
      buttonImage: "/themes/bas/icons/fatcow/16x16/calendar.png",
      dateFormat:'dd-mm-yy',
      timeFormat: 'HH:mm',
      buttonImageOnly: true,
      controlType: 'select',
      showWeek: true,
      firstDay: 1,
      oneLine : true
      });
      var today = new Date();
      var tomorrow = new Date();
      tomorrow.setDate(today.getDate()+1);
      tomorrow.setHours(8);
      tomorrow.setMinutes(0);
      $(".reopenTicket").datetimepicker("setDate", new Date(tomorrow));
      EOS
      );
      ?>


      And here is my js file :



          var REMINDER = {};

      REMINDER.Followupreminder = {

      };


      inside that



       REMINDER.Followupreminder = {

      };


      function i would like to call that js code.



      Can anyone help me how can i do that.
      Thanks in advance.







      javascript zend-framework






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 16 '18 at 4:55









      sureshsuresh

      29410




      29410
























          1 Answer
          1






          active

          oldest

          votes


















          1














          once you provided additional info (initial request was out of context) here's something similar to your sample:



          var REMINDER = {};

          REMINDER.Followupreminder = {

          init: function(){
          // put your any initialization here
          this.bindUI();
          },

          bindUI: function(){
          // if bindUI isn't being used from outside - you may call this.initDatePicker() directly from init()
          this.initDatePicker();
          },

          initDatePicker: function () {
          console.log('Congratulations! Your code has been moved and executed!');
          $(".reopenTicket").datetimepicker({
          showOn: "button",
          buttonImage: "/themes/bas/icons/fatcow/16x16/calendar.png",
          dateFormat: 'dd-mm-yy',
          timeFormat: 'HH:mm',
          buttonImageOnly: true,
          controlType: 'select',
          showWeek: true,
          firstDay: 1,
          oneLine: true
          });
          var today = new Date();
          var tomorrow = new Date();
          tomorrow.setDate(today.getDate() + 1);
          tomorrow.setHours(8);
          tomorrow.setMinutes(0);
          $(".reopenTicket").datetimepicker("setDate", new Date(tomorrow));
          }
          };

          $(function(){
          REMINDER.Followupreminder.init();
          });





          share|improve this answer


























          • i am getting formal parameter name expected from this line $(".reopenTicket").datetimepicker({

            – suresh
            Nov 16 '18 at 5:04











          • no actually i would like to keep my js code inside my REMINDER.Followupreminder = { };

            – suresh
            Nov 16 '18 at 5:06











          • but the synax you used {} is not a function, it's an object, you can't place executable code there. Unless you add some method. Not enough info yet to help you. Provide a sample of how you want to call your function

            – Roman86
            Nov 16 '18 at 5:09








          • 1





            codeshare.io/5znKLb check that we used to follow this kind of structure in my office to the js code

            – suresh
            Nov 16 '18 at 5:10








          • 1





            yes i want my code to be like what i have shown in my example file

            – suresh
            Nov 16 '18 at 5:17











          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%2f53331675%2fmove-js-code-from-html-page-to-js-file-and-call-that-code-in-my-html-page%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














          once you provided additional info (initial request was out of context) here's something similar to your sample:



          var REMINDER = {};

          REMINDER.Followupreminder = {

          init: function(){
          // put your any initialization here
          this.bindUI();
          },

          bindUI: function(){
          // if bindUI isn't being used from outside - you may call this.initDatePicker() directly from init()
          this.initDatePicker();
          },

          initDatePicker: function () {
          console.log('Congratulations! Your code has been moved and executed!');
          $(".reopenTicket").datetimepicker({
          showOn: "button",
          buttonImage: "/themes/bas/icons/fatcow/16x16/calendar.png",
          dateFormat: 'dd-mm-yy',
          timeFormat: 'HH:mm',
          buttonImageOnly: true,
          controlType: 'select',
          showWeek: true,
          firstDay: 1,
          oneLine: true
          });
          var today = new Date();
          var tomorrow = new Date();
          tomorrow.setDate(today.getDate() + 1);
          tomorrow.setHours(8);
          tomorrow.setMinutes(0);
          $(".reopenTicket").datetimepicker("setDate", new Date(tomorrow));
          }
          };

          $(function(){
          REMINDER.Followupreminder.init();
          });





          share|improve this answer


























          • i am getting formal parameter name expected from this line $(".reopenTicket").datetimepicker({

            – suresh
            Nov 16 '18 at 5:04











          • no actually i would like to keep my js code inside my REMINDER.Followupreminder = { };

            – suresh
            Nov 16 '18 at 5:06











          • but the synax you used {} is not a function, it's an object, you can't place executable code there. Unless you add some method. Not enough info yet to help you. Provide a sample of how you want to call your function

            – Roman86
            Nov 16 '18 at 5:09








          • 1





            codeshare.io/5znKLb check that we used to follow this kind of structure in my office to the js code

            – suresh
            Nov 16 '18 at 5:10








          • 1





            yes i want my code to be like what i have shown in my example file

            – suresh
            Nov 16 '18 at 5:17
















          1














          once you provided additional info (initial request was out of context) here's something similar to your sample:



          var REMINDER = {};

          REMINDER.Followupreminder = {

          init: function(){
          // put your any initialization here
          this.bindUI();
          },

          bindUI: function(){
          // if bindUI isn't being used from outside - you may call this.initDatePicker() directly from init()
          this.initDatePicker();
          },

          initDatePicker: function () {
          console.log('Congratulations! Your code has been moved and executed!');
          $(".reopenTicket").datetimepicker({
          showOn: "button",
          buttonImage: "/themes/bas/icons/fatcow/16x16/calendar.png",
          dateFormat: 'dd-mm-yy',
          timeFormat: 'HH:mm',
          buttonImageOnly: true,
          controlType: 'select',
          showWeek: true,
          firstDay: 1,
          oneLine: true
          });
          var today = new Date();
          var tomorrow = new Date();
          tomorrow.setDate(today.getDate() + 1);
          tomorrow.setHours(8);
          tomorrow.setMinutes(0);
          $(".reopenTicket").datetimepicker("setDate", new Date(tomorrow));
          }
          };

          $(function(){
          REMINDER.Followupreminder.init();
          });





          share|improve this answer


























          • i am getting formal parameter name expected from this line $(".reopenTicket").datetimepicker({

            – suresh
            Nov 16 '18 at 5:04











          • no actually i would like to keep my js code inside my REMINDER.Followupreminder = { };

            – suresh
            Nov 16 '18 at 5:06











          • but the synax you used {} is not a function, it's an object, you can't place executable code there. Unless you add some method. Not enough info yet to help you. Provide a sample of how you want to call your function

            – Roman86
            Nov 16 '18 at 5:09








          • 1





            codeshare.io/5znKLb check that we used to follow this kind of structure in my office to the js code

            – suresh
            Nov 16 '18 at 5:10








          • 1





            yes i want my code to be like what i have shown in my example file

            – suresh
            Nov 16 '18 at 5:17














          1












          1








          1







          once you provided additional info (initial request was out of context) here's something similar to your sample:



          var REMINDER = {};

          REMINDER.Followupreminder = {

          init: function(){
          // put your any initialization here
          this.bindUI();
          },

          bindUI: function(){
          // if bindUI isn't being used from outside - you may call this.initDatePicker() directly from init()
          this.initDatePicker();
          },

          initDatePicker: function () {
          console.log('Congratulations! Your code has been moved and executed!');
          $(".reopenTicket").datetimepicker({
          showOn: "button",
          buttonImage: "/themes/bas/icons/fatcow/16x16/calendar.png",
          dateFormat: 'dd-mm-yy',
          timeFormat: 'HH:mm',
          buttonImageOnly: true,
          controlType: 'select',
          showWeek: true,
          firstDay: 1,
          oneLine: true
          });
          var today = new Date();
          var tomorrow = new Date();
          tomorrow.setDate(today.getDate() + 1);
          tomorrow.setHours(8);
          tomorrow.setMinutes(0);
          $(".reopenTicket").datetimepicker("setDate", new Date(tomorrow));
          }
          };

          $(function(){
          REMINDER.Followupreminder.init();
          });





          share|improve this answer















          once you provided additional info (initial request was out of context) here's something similar to your sample:



          var REMINDER = {};

          REMINDER.Followupreminder = {

          init: function(){
          // put your any initialization here
          this.bindUI();
          },

          bindUI: function(){
          // if bindUI isn't being used from outside - you may call this.initDatePicker() directly from init()
          this.initDatePicker();
          },

          initDatePicker: function () {
          console.log('Congratulations! Your code has been moved and executed!');
          $(".reopenTicket").datetimepicker({
          showOn: "button",
          buttonImage: "/themes/bas/icons/fatcow/16x16/calendar.png",
          dateFormat: 'dd-mm-yy',
          timeFormat: 'HH:mm',
          buttonImageOnly: true,
          controlType: 'select',
          showWeek: true,
          firstDay: 1,
          oneLine: true
          });
          var today = new Date();
          var tomorrow = new Date();
          tomorrow.setDate(today.getDate() + 1);
          tomorrow.setHours(8);
          tomorrow.setMinutes(0);
          $(".reopenTicket").datetimepicker("setDate", new Date(tomorrow));
          }
          };

          $(function(){
          REMINDER.Followupreminder.init();
          });






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 16 '18 at 6:25

























          answered Nov 16 '18 at 5:01









          Roman86Roman86

          846610




          846610













          • i am getting formal parameter name expected from this line $(".reopenTicket").datetimepicker({

            – suresh
            Nov 16 '18 at 5:04











          • no actually i would like to keep my js code inside my REMINDER.Followupreminder = { };

            – suresh
            Nov 16 '18 at 5:06











          • but the synax you used {} is not a function, it's an object, you can't place executable code there. Unless you add some method. Not enough info yet to help you. Provide a sample of how you want to call your function

            – Roman86
            Nov 16 '18 at 5:09








          • 1





            codeshare.io/5znKLb check that we used to follow this kind of structure in my office to the js code

            – suresh
            Nov 16 '18 at 5:10








          • 1





            yes i want my code to be like what i have shown in my example file

            – suresh
            Nov 16 '18 at 5:17



















          • i am getting formal parameter name expected from this line $(".reopenTicket").datetimepicker({

            – suresh
            Nov 16 '18 at 5:04











          • no actually i would like to keep my js code inside my REMINDER.Followupreminder = { };

            – suresh
            Nov 16 '18 at 5:06











          • but the synax you used {} is not a function, it's an object, you can't place executable code there. Unless you add some method. Not enough info yet to help you. Provide a sample of how you want to call your function

            – Roman86
            Nov 16 '18 at 5:09








          • 1





            codeshare.io/5znKLb check that we used to follow this kind of structure in my office to the js code

            – suresh
            Nov 16 '18 at 5:10








          • 1





            yes i want my code to be like what i have shown in my example file

            – suresh
            Nov 16 '18 at 5:17

















          i am getting formal parameter name expected from this line $(".reopenTicket").datetimepicker({

          – suresh
          Nov 16 '18 at 5:04





          i am getting formal parameter name expected from this line $(".reopenTicket").datetimepicker({

          – suresh
          Nov 16 '18 at 5:04













          no actually i would like to keep my js code inside my REMINDER.Followupreminder = { };

          – suresh
          Nov 16 '18 at 5:06





          no actually i would like to keep my js code inside my REMINDER.Followupreminder = { };

          – suresh
          Nov 16 '18 at 5:06













          but the synax you used {} is not a function, it's an object, you can't place executable code there. Unless you add some method. Not enough info yet to help you. Provide a sample of how you want to call your function

          – Roman86
          Nov 16 '18 at 5:09







          but the synax you used {} is not a function, it's an object, you can't place executable code there. Unless you add some method. Not enough info yet to help you. Provide a sample of how you want to call your function

          – Roman86
          Nov 16 '18 at 5:09






          1




          1





          codeshare.io/5znKLb check that we used to follow this kind of structure in my office to the js code

          – suresh
          Nov 16 '18 at 5:10







          codeshare.io/5znKLb check that we used to follow this kind of structure in my office to the js code

          – suresh
          Nov 16 '18 at 5:10






          1




          1





          yes i want my code to be like what i have shown in my example file

          – suresh
          Nov 16 '18 at 5:17





          yes i want my code to be like what i have shown in my example file

          – suresh
          Nov 16 '18 at 5:17




















          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%2f53331675%2fmove-js-code-from-html-page-to-js-file-and-call-that-code-in-my-html-page%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

          Xamarin.iOS Cant Deploy on Iphone

          Glorious Revolution

          Dulmage-Mendelsohn matrix decomposition in Python