Pasar una variable declarada en una vista a javascript

I stuck in this part.

I have declared a integer variable called "count"

@{
    int count = 6;
}

I have a slider as well.

<input name="sliderStatus"  id="sliderStatus" onchange="updateThumbnail(this, @count)" type="range" min="0" max="100" value="0" step="1"/>

I have script something like this...

    <script type="text/javascript">
    function updateThumbnail(rangeInput, count) {
        var previousImage = document.getElementById('someImage' + rangeInput / (rangeInput.value / count));
        if (previousImage) {
            previousImage.style.display = 'none';
        }
        var nextImage = document.getElementById('someImage' + rangeInput / (rangeInput.value / count));
        nextImage.style.display = 'block';
    }
</script>

The script turns out that it cannot recognize the "count" in the script. How do it pass the variable from the view into the script? Help appreciated. :(

preguntado el 04 de julio de 12 a las 05:07

1 Respuestas

tratan

@{
    int count = 6;
}

<script type="text/javascript">

var $count = '@count';

</sxript>

Respondido 04 Jul 12, 05:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.