Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to fix a non persistent javascript function
    primarykey
    data
    text
    <p>I have created a slider in an ASP.NET page by using AJAX contol Toolkit. To increase and decrease the value of slider, I have also placed a "plus" &amp; a "minus" button. On the client click event of each button I have used a javascript function that will do some calculations and show it as a asp:label below the slider. Now the problem is if I change the value of slider by dragging it, the function is called and the calculations are shown as a label but, if I change the value of the slider by the buttons ("plus" or "minus" button), the function is called but calculations are shown only for couple of seconds as a label. After 1 2 seconds the label is gone, showing nothing.</p> <p>Does anyone have any idea about my problem?</p> <p>Here is the code:</p> <ol> <li><p>"Plus" Button: <code>&lt;asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/icon_plus1.jpg" style="z-index: 1; left: 830px; top: 130px; position: absolute" onclientclick="change1();"/&gt;</code></p></li> <li><p>This is the function that i am calling: <code>function change1() { var object = document.getElementById("TextBox"); var val = object.value; object.value = parseInt(val) + 5; updatesum(); }</code></p></li> <li><p>The main calculation is in the updatesum() function:</p> <pre><code>function updatesum() { var principal = slider1Value; var daily_interest_rate = eval((360 / 100) / 365); var transaction_fee = eval(5.50); var number_of_days = slider2Value; var due_date = addDays(eval(number_of_days)).toDateString(); var interest_amount = (eval(daily_interest_rate) * eval(number_of_days) * eval(eval(principal) + eval(transaction_fee))) + eval(transaction_fee); var total_amount = interest_amount + eval(principal); lblDate.innerHTML = due_date; lblBorrow.innerHTML = "&amp;pound " + slider1Value; lblInter.innerHTML = "&amp;pound " + interest_amount.toFixed(2); lblRepay.innerHTML = "&amp;pound " + total_amount.toFixed(2); } </code></pre></li> <li><p>The Slider and its Target Control ID Textbox:</p> <pre><code>&lt;ajaxToolkit:SliderExtender ID="SliderExtender2" runat="server" length="400" Enabled="True" Maximum="400" Minimum="0" Steps="80" TargetControlID="TextBox" BoundControlID="TextBox1" RailCssClass="SliderRail"&gt; &lt;/ajaxToolkit:SliderExtender&gt; &lt;asp:TextBox ID="TextBox" runat="server" OnChange ="javascript:updatesum(this);" style="z-index: 1; top: 130px; position: absolute; left: 430px; bottom: 130px" </code></pre> <h2> </h2></li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload