I have a variable locally defined in my View. I am setting it to 1 under some conditions. I want to pass this variable to the script in order to have a condition based on it that decides if an audio is played or not.
How can I pass alarm variable to my javascript?
@{
int alarm = 0;
}
@foreach (var item in Model)
{
if (ViewBag.Dtype == "1")
{
alarm = 1;
}
}
<script type="text/javascript">
$(document).ready(function () {
document.getElementById('player').play()});
</script>