Click here to Skip to main content
15,895,667 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: Text editor Pin
Pete O'Hanlon28-Aug-12 3:06
mvePete O'Hanlon28-Aug-12 3:06 
GeneralRe: Text editor Pin
BobJanova28-Aug-12 3:31
BobJanova28-Aug-12 3:31 
AnswerRe: Text editor Pin
Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)28-Aug-12 3:56
protectorTadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)28-Aug-12 3:56 
GeneralRe: Text editor Pin
R. Giskard Reventlov28-Aug-12 9:41
R. Giskard Reventlov28-Aug-12 9:41 
AnswerRe: Text editor Pin
Joan M28-Aug-12 10:00
professionalJoan M28-Aug-12 10:00 
Questionautomatically checking a check box in a website. Pin
saadmechiche26-Aug-12 22:20
saadmechiche26-Aug-12 22:20 
AnswerRe: automatically checking a check box in a website. Pin
Shameel28-Aug-12 3:35
professionalShameel28-Aug-12 3:35 
Questionmy function really slows down after 4 times Pin
jkirkerx26-Aug-12 16:34
professionaljkirkerx26-Aug-12 16:34 
I wrote this, and after changing the value of the dropdown like 20 times, I noticed the function got slower and slower until I was not able to select a value after about 6 times. I tried optimizing it, it was 3 times, now 6.

Not quite sure where I dropped the ball at here, or what is consuming large amounts or resources.

So instead of going back to the server to get fresh values, I just took them from the html in the option list of the dropdownlist, and parsed out the values I wanted.

Anyways, any insight would be appreciated.


$('[id*="_ddl_EstimateShipping_RateAPICode"]').change(function () {
        
   var option_Textline = $(this).find(":selected").text();
   if (option_Textline != "") {

      // Parse the option_Textline
      var n = option_Textline.indexOf("--");
      var option_RateName = option_Textline.substring(0, n).trim();
      var option_RatePrice = option_Textline.substring(n + 2, option_Textline.length).trim();

      // Strip all the alpha-numeric chars from the value
      option_RatePrice = parseFloat(option_RatePrice.replace(/[A-Za-z$-]/g, ""));

            $('[id*="_lbl_Information_ShipRatePlan"]').text(option_RateName);
            $('[id*="_lbl_Information_ShipRatePrice"]').text("$" + option_RatePrice);

      // Update the Estimated Shopping Cart Totals
      var n_ProductTotals = $('[id*="_txt_Helper_ProductTotals_Field"]').val();
      var o_PromoDiscount = $('[id*="_lbl_PromoCode"]').text();
      var o_GCertificate = $('[id*="_lbl_SubTotals_GiftCertificates"]').text();
      var o_SalesTax = $('[id*="_lbl_SubTotals_SalesTax"]').text();

      o_PromoDiscount = parseFloat(o_PromoDiscount.replace(/\$/g, "").replace(/\-/g, ""));
      o_GCertificate = parseFloat(o_GCertificate.replace(/\$/g, "").replace(/\-/g, ""));
      o_SalesTax = parseFloat(o_SalesTax.replace(/\$/g, ""));

      var n_SubTotal = parseFloat(n_ProductTotals - parseFloat(o_PromoDiscount));
      var n_GrandTotal = parseFloat(parseFloat(n_SubTotal) + parseFloat(option_RatePrice) + parseFloat(o_SalesTax) - parseFloat(o_GCertificate));

      if (!isNaN(n_SubTotal)) {
          //n_SubTotal = Math.round(n_SubTotal * 100) / 100
          $('[id*="_lbl_DisplayShoppingCart_SubTotals_SubTotal"]').text("$" + n_SubTotal.toFixed(2));
      }

      if (!isNaN(option_RatePrice)) {
          //option_RatePrice = Math.round(option_RatePrice * 100) / 100
          $('[id*="_lbl_SubTotals_Shipping"]').text("$" + option_RatePrice.toFixed(2));
            }

      if (!isNaN(n_GrandTotal)) {
          //n_GrandTotal = Math.round(n_GrandTotal * 100) / 100
          $('[id*="_lbl_SubTotals_GrandTotal"]').text("$" + n_GrandTotal.toFixed(2));
      }
  }

    });

    return false;
    
}

AnswerRe: my function really slows down after 4 times Pin
jkirkerx28-Aug-12 8:55
professionaljkirkerx28-Aug-12 8:55 
Questiontrouble using each in json array Pin
jkirkerx23-Aug-12 12:56
professionaljkirkerx23-Aug-12 12:56 
AnswerRe: trouble using each in json array Pin
BobJanova23-Aug-12 22:47
BobJanova23-Aug-12 22:47 
GeneralRe: trouble using each in json array Pin
jkirkerx24-Aug-12 6:32
professionaljkirkerx24-Aug-12 6:32 
QuestionHow to calculate difference between two date Pin
Robymon21-Aug-12 23:11
Robymon21-Aug-12 23:11 
AnswerRe: How to calculate difference between two date Pin
BobJanova22-Aug-12 0:33
BobJanova22-Aug-12 0:33 
QuestionHow to add Days in variable Date Pin
Robymon21-Aug-12 21:40
Robymon21-Aug-12 21:40 
AnswerRe: How to add Days in variable Date Pin
Pete O'Hanlon21-Aug-12 22:26
mvePete O'Hanlon21-Aug-12 22:26 
Questionget all image file names from a folder in Jquery Pin
ashjassi19-Aug-12 19:33
ashjassi19-Aug-12 19:33 
Questionintegrate bidichecker to awebsite Pin
nada200615-Aug-12 17:42
nada200615-Aug-12 17:42 
Questioneither my css or Javscript is in error, another set of eyes Pin
jkirkerx15-Aug-12 13:19
professionaljkirkerx15-Aug-12 13:19 
AnswerRe: either my css or Javscript is in error, another set of eyes Pin
jkirkerx15-Aug-12 16:32
professionaljkirkerx15-Aug-12 16:32 
AnswerRe: either my css or Javscript is in error, another set of eyes Pin
BobJanova15-Aug-12 23:36
BobJanova15-Aug-12 23:36 
QuestionDisplay Values Pin
lakshmiblp15-Aug-12 10:29
lakshmiblp15-Aug-12 10:29 
Questionhow to get default signature in outlook using Javascript Pin
Anurag Sinha V9-Aug-12 2:20
Anurag Sinha V9-Aug-12 2:20 
AnswerRe: how to get default signature in outlook using Javascript Pin
Pete O'Hanlon9-Aug-12 3:52
mvePete O'Hanlon9-Aug-12 3:52 
AnswerRe: how to get default signature in outlook using Javascript Pin
BobJanova9-Aug-12 3:56
BobJanova9-Aug-12 3:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.