I have a button and when i click on the button I launch a javascript function (progress bar)
<asp:Button ID="btn_tel" runat="server" CausesValidation="False" OnClick="btn_telefono" Text="Controlla" CssClass="button" OnClientClick="move()" /></div>
Function move():
<script type="text/javascript">
function move() {
setTimeout(function () {
var elem = document.getElementById("myBar");
elem.style.color = "White";
var width = 0;
var temp= "<%=intervallo%>";
var id = setInterval(frame, temp);
function frame() {
if (width >= 100) {
clearInterval(id);
} else {
width++;
elem.style.width = width + '%';
elem.innerHTML = width * 1 + '%';
}
}
}, 0)
}
</script>
In my code I can set the variable "intervallo" .
The code works, but i want to pass the variable intervallo when i click on the button.
I tried in several ways but I did not succeed. Do you have any idea?
Thanks
I believe the easiest way is to add a parameter to your function:
function move(var x) {
...
}
Then, in the page call the method with:
...onClientClick="move(x)"
Replace x in the method call with the value you want to pass to the function.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.