0

このコード行の構文の何が問題なのか誰か教えてくれませんか? Dreamweaver で、次の場所で構文エラーが発生します。

values: [${command.schedule.startTime.minutesFromMidnight},
            ${command.schedule.stopTime.minutesFromMidnight}],

以下の完全な JavaScript コード:

<script language="javascript">
   function slideTime(from_position, to_position){
     var from = parseInt(from_position);
     var to = parseInt(to_position);
     if(from > (23*60)+45) {
     return false;
   }
  if(from >= to) {
     return false;
   }
  var minutes0 = parseInt(from % 60);
  var hours0 = parseInt(from / 60 % 24);
  var minutes1 = parseInt(to % 60);
  var hours1 = parseInt(to / 60 % 24);
  if(getTime(hours0, minutes0) == getTime(hours1, minutes1)){
     to = to - 15;
     minutes1 = parseInt(to % 60);
     hours1 = parseInt(to / 60 % 24);
     }
  $("#time").val(getTime(hours0, minutes0) + ' - ' + getTime(hours1, minutes1));
  $("#schedule\\.startTime\\.minutesFromMidnight").val(from);
  $("#schedule\\.stopTime\\.minutesFromMidnight").val(to);
  }
  function getTime(hours, minutes) {
     var time = null;
     minutes = minutes + "";
     if (hours < 12) {
     time = "AM";
     }
     else {
     time = "PM";
     }
      if (hours == 0) {
     hours = 12;
     }
     if (hours > 12) {
     hours = hours - 12;
     }
     if (minutes.length == 1) {
     minutes = "0" + minutes;
     }
      return hours + ":" + minutes + " " + time;
     } 
</script>


<script language="javascript">
   $(document).ready(function() {
   $("#slider-range").slider({
   range: true,
   min: 0,
   max: 1680,
   values: [${command.schedule.startTime.minutesFromMidnight},
            ${command.schedule.stopTime.minutesFromMidnight}],
   slide: function(event, ui) {
          var from = ui.values[0];
          var to = ui.values[1];
          return slideTime(from, to);
   },
   step:15
   });
 });
</script>

HTML

<div id="slider-range"></div>

コードはブラウザーで実行されません。私はコードを書きませんでしたが、再利用するために私に与えられました。ありがとう。

4

1 に答える 1

-2
<script language="javascript">
   function slideTime(from_position, to_position){
     var from = parseInt(from_position);
     var to = parseInt(to_position);
     if(from > (23*60)+45) {
     return false;
   }
  if(from >= to) {
     return false;
   }
  var minutes0 = parseInt(from % 60);
  var hours0 = parseInt(from / 60 % 24);
  var minutes1 = parseInt(to % 60);
  var hours1 = parseInt(to / 60 % 24);
  if(getTime(hours0, minutes0) == getTime(hours1, minutes1)){
     to = to - 15;
     minutes1 = parseInt(to % 60);
     hours1 = parseInt(to / 60 % 24);
     }
  $("#time").val(getTime(hours0, minutes0) + ' - ' + getTime(hours1, minutes1));
  $("#schedule\\.startTime\\.minutesFromMidnight").val(from);
  $("#schedule\\.stopTime\\.minutesFromMidnight").val(to);
  }
  function getTime(hours, minutes) {
     var time = null;
     minutes = minutes + "";
     if (hours < 12) {
     time = "AM";
     }
     else {
     time = "PM";
     }
      if (hours == 0) {
     hours = 12;
     }
     if (hours > 12) {
     hours = hours - 12;
     }
     if (minutes.length == 1) {
     minutes = "0" + minutes;
     }
      return hours + ":" + minutes + " " + time;
     } 
</script>


<script language="javascript">
   $(document).ready(function() {
   $("#slider-range").slider({
   range: true,
   min: 0,
   max: 1680,
   values: [$command.schedule.startTime.minutesFromMidnight,
            $command.schedule.stopTime.minutesFromMidnight],
   slide: function(event, ui) {
          var from = ui.values[0];
          var to = ui.values[1];
          return slideTime(from, to);
   },
   step:15
   });
 });
</script>

このコードを使用してください..

于 2012-05-22T13:47:40.753 に答える