Javascript 以js格式检索日期
我有这样的代码:Javascript 以js格式检索日期,javascript,php,Javascript,Php,我有这样的代码: if(substr($field, -7)=="StartDate"){ // If change start date $end = str_replace('StartDate', 'EndDate', $field); if (property_exists($this, $end)) { echo "if(!this.value) {"; echo " var end = dijit.byId('$en
if(substr($field, -7)=="StartDate"){
// If change start date
$end = str_replace('StartDate', 'EndDate', $field);
if (property_exists($this, $end)) {
echo "if(!this.value) {";
echo " var end = dijit.byId('$end').get('value');"; // $end will be replaced by value as enclosed by "
echo " if(end){";
echo " var dtStart = $this.value;"; // => I need to retrive the date of $this in format js
echo " end.constraints.min=dtSatrt;";
echo " }";
echo "}";
}
}
对于行
echo“var dtStart=$this.value;”;//=>我需要以js格式检索$this的日期,你能帮我吗?谢谢 只需在函数周围回显标记,当它以html格式输出时,脚本将运行
echo"<script>var dtStart = " . $this.value . "</script>";
echo“var dtStart=”$这就是价值。"";
您可能需要调整输出的格式。您好。是的,但像这样,我没有以js格式检索日期:(你能给我一个示例输出,这样我就知道你使用的是什么了>,你需要先格式化$this.value,然后才能将其回送到js代码中。你必须回送$this['value']或者如果对象$this->value通过java脚本中的php。因为我在java脚本中的$this中没有看到任何变量或名称为的对象。