开发者

Javascript crashes my Dojo in Zend Framework

I got problem with JavaScript and Dojo in my Zend Framework project. I got 4 sliders (HorizontalSlider) created by Form in Zend. Every slider get other value and this value i want to display near the sliders. So i got the code in 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/>"
}

And in form in Zend:

   $thi开发者_JS百科s->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ł'
        ),
            )
    );

Changing it to:

$cena->setAttrib('onChange','getText()');

Dont work too. When i delete this lines everything works. And this work but when i press Submit i got static value for cena - 2000. JS shows good value. Whats wrong? Please help or I die here... :/


Quick syntax error note: Your function is missing ; at the end of every line. Try this it might help.

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/>";
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜