我在Zend Framework项目中遇到了JavaScript和Dojo的问题。我有一个由Zend中的Form创建的4个滑块(HorizontalSlider)。每个滑块都获得其他值,我想在滑块附近显示此值。所以我在JS中获得了代码:
function getText(){
var cena = document.getElementById("slider-400")
var waga = document.getElementById("slider-100")
var bateria = document.getElementById("slider-700")
var cale = document.getElementById("slider-1")
var div = document.getElementById("znajdz-contents")
div.innerHTML = "Cena : "+(Round(cena.value,2))+" <br/>" + "Waga : "+(Round(waga.value,2))+" <br/>" + "Bateria : "+(Round(bateria.value,2))+" <br/>" + "Wyswietlacz : "+(Round(cale.value,2))+" <br/>"
}
以Zend的形式出现:
$this->addElement(
'HorizontalSlider', 'cena', array(
'label' => 'Maksymalna cena',
'value' => 2000,
'onchange' =>"getText()"
'minimum' => 400,
'maximum' => 2000,
'discreteValues' => $discrete,
'intermediateChanges' => false,
'showButtons' => false,
'topDecorationDijit' => 'HorizontalRuleLabels',
'topDecorationContainer' => 'topContainer',
'bottomDecorationDijit' => 'HorizontalRule',
'bottomDecorationContainer' => 'bottomContainer',
'bottomDecorationLabels' => array(
'400zł',
'1200zł',
'2000zł'
),
)
);
将其更改为:
$cena->setAttrib('onChange','getText()');
也不要工作。当我删除这一行时一切正常。 而这项工作,但当我按提交我有静态值为cena - 2000. JS显示良好的价值。怎么了?请帮忙或我死在这里......:/
答案 0 :(得分:0)
快速语法错误提示:您的功能在每行末尾都缺少;
。试试这可能会有所帮助。
function getText(){
var cena = document.getElementById("slider-400");
var waga = document.getElementById("slider-100");
var bateria = document.getElementById("slider-700");
var cale = document.getElementById("slider-1");
var div = document.getElementById("znajdz-contents");
div.innerHTML = "Cena : "+Round(cena.value,2).ToString()+" <br/>" +
"Waga : "+Round(waga.value,2).ToString()+" <br/>" +
"Bateria : "+Round(bateria.value,2).ToString()+" <br/>" +
"Wyswietlacz : "+Round(cale.value,2).ToString()+" <br/>";
}