html - How to make Javascript write price based on input? -


here fiddle, can see i'm talking about.

basically price checker, , need use javascript in order display values.

so can see have div .offer have offer call action. when user loads page, div display “please select country”

after pressing “check prices” paragraph displayed price , yellow button under it. so, question is, how do this? how can create script checks both values ,“to” , “from” in order display appropriate price? example, if chooses germany united states, should display $0.02/minute. if choose spain italy, should display $0.05/minute etc. hope idea.

thanks in advance :)

<div class="offer">   <p>our special offer is:</p>   <p id="big-offer">only $0.01/min</p>   <button type="submit" class="btn btn-default btn-lg" id="big-cta">strong call action!</button> </div> 

i built similar while client, it's ugly hell , lot more dry, works. quote generator takes 3 parameters: services, bedrooms , furnishings , returns value. should able tweak suit needs. if you'd see working can check out here. singleton:

var quotemaker = {         data : {             'services':null,             'bedrooms':null,             'furnishing':null,             'quotestring':''         },         serviceslistener : function(){            this.data.services = document.getelementbyid('service').options[document.getelementbyid('service').selectedindex].text;         },         bedroomslistener : function(){            this.data.bedrooms = document.getelementbyid('bedrooms').options[document.getelementbyid('bedrooms').selectedindex].text;         },         furnishinglistener : function(){            this.data.furnishing = document.getelementbyid('furnishing').options[document.getelementbyid('furnishing').selectedindex].text;         },         changedata : function(divobj){             this.data.quotestring='';             if( divobj.id == 'service' ){                 this.serviceslistener();             }else if( divobj.id == 'bedrooms' ){                 this.bedroomslistener();             }else if( divobj.id == 'furnishing' ){                 this.furnishinglistener();             }             this.updatequote();         },     updatequote : function() {       if (this.data.services == "inventory" &&this.data.bedrooms =="1" && this.data.furnishing == "furnished")           this.data.quotestring = "= £70";        if (this.data.services == "inventory" &&this.data.bedrooms =="2" && this.data.furnishing == "furnished")           this.data.quotestring = "= £75";       if (this.data.services == "inventory" &&this.data.bedrooms =="3" && this.data.furnishing == "furnished")           this.data.quotestring = "= £80";       if (this.data.services == "inventory" &&this.data.bedrooms =="4" && this.data.furnishing == "furnished")           this.data.quotestring = "= £85";       if (this.data.services == "inventory" &&this.data.bedrooms =="5" && this.data.furnishing == "furnished")           this.data.quotestring = "= £90";       if (this.data.services == "inventory" &&this.data.bedrooms =="6+" && this.data.furnishing == "furnished")           this.data.quotestring = "= £100";        if (this.data.services == "inventory" &&this.data.bedrooms =="1" && this.data.furnishing == "part furnished")           this.data.quotestring = "= £60";        if (this.data.services == "inventory" &&this.data.bedrooms =="2" && this.data.furnishing == "part furnished")           this.data.quotestring = "= £65";       if (this.data.services == "inventory" &&this.data.bedrooms =="3" && this.data.furnishing == "part furnished")           this.data.quotestring = "= £70";       if (this.data.services == "inventory" &&this.data.bedrooms =="4" && this.data.furnishing == "part furnished")           this.data.quotestring = "= £75";       if (this.data.services == "inventory" &&this.data.bedrooms =="5" && this.data.furnishing == "part furnished")           this.data.quotestring = "= £80";       if (this.data.services == "inventory" &&this.data.bedrooms =="6+" && this.data.furnishing == "part furnished")           this.data.quotestring = "= £85";        if (this.data.services == "inventory" &&this.data.bedrooms =="1" && this.data.furnishing == "unfurnished (except white goods)")           this.data.quotestring = "= £55";        if (this.data.services == "inventory" &&this.data.bedrooms =="2" && this.data.furnishing == "unfurnished (except white goods)")           this.data.quotestring = "= £60";       if (this.data.services == "inventory" &&this.data.bedrooms =="3" && this.data.furnishing == "unfurnished (except white goods)")           this.data.quotestring = "= £65";       if (this.data.services == "inventory" &&this.data.bedrooms =="4" && this.data.furnishing == "unfurnished (except white goods)")           this.data.quotestring = "= £70";       if (this.data.services == "inventory" &&this.data.bedrooms =="5" && this.data.furnishing == "unfurnished (except white goods)")           this.data.quotestring = "= £75";       if (this.data.services == "inventory" &&this.data.bedrooms =="6+" && this.data.furnishing == "unfurnished (except white goods)")           this.data.quotestring = "= £80";         if (this.data.services == "check-in" &&this.data.bedrooms =="1" && this.data.furnishing == "furnished")           this.data.quotestring = "= £50";        if (this.data.services == "check-in" &&this.data.bedrooms =="2" && this.data.furnishing == "furnished")           this.data.quotestring = "= £55";       if (this.data.services == "check-in" &&this.data.bedrooms =="3" && this.data.furnishing == "furnished")           this.data.quotestring = "= £60";       if (this.data.services == "check-in" &&this.data.bedrooms =="4" && this.data.furnishing == "furnished")           this.data.quotestring = "= £65";       if (this.data.services == "check-in" &&this.data.bedrooms =="5" && this.data.furnishing == "furnished")           this.data.quotestring = "= £70";       if (this.data.services == "check-in" &&this.data.bedrooms =="6+" && this.data.furnishing == "furnished")           this.data.quotestring = "= £75";        if (this.data.services == "check-in" &&this.data.bedrooms =="1" && this.data.furnishing == "part furnished")           this.data.quotestring = "= £40";        if (this.data.services == "check-in" &&this.data.bedrooms =="2" && this.data.furnishing == "part furnished")           this.data.quotestring = "= £45";       if (this.data.services == "check-in" &&this.data.bedrooms =="3" && this.data.furnishing == "part furnished")           this.data.quotestring = "= £50";       if (this.data.services == "check-in" &&this.data.bedrooms =="4" && this.data.furnishing == "part furnished")           this.data.quotestring = "= £55";       if (this.data.services == "check-in" &&this.data.bedrooms =="5" && this.data.furnishing == "part furnished")           this.data.quotestring = "= £60";       if (this.data.services == "check-in" &&this.data.bedrooms =="6+" && this.data.furnishing == "part furnished")           this.data.quotestring = "= £65";        if (this.data.services == "check-in" &&this.data.bedrooms =="1" && this.data.furnishing == "unfurnished (except white goods)")           this.data.quotestring = "= £35";        if (this.data.services == "check-in" &&this.data.bedrooms =="2" && this.data.furnishing == "unfurnished (except white goods)")           this.data.quotestring = "= £40";       if (this.data.services == "check-in" &&this.data.bedrooms =="3" && this.data.furnishing == "unfurnished (except white goods)")           this.data.quotestring = "= £45";       if (this.data.services == "check-in" &&this.data.bedrooms =="4" && this.data.furnishing == "unfurnished (except white goods)")           this.data.quotestring = "= £50";       if (this.data.services == "check-in" &&this.data.bedrooms =="5" && this.data.furnishing == "unfurnished (except white goods)")           this.data.quotestring = "= £55";       if (this.data.services == "check-in" &&this.data.bedrooms =="6+" && this.data.furnishing == "unfurnished (except white goods)")           this.data.quotestring = "= £60";         if (this.data.services == "check-out" &&this.data.bedrooms =="1" && this.data.furnishing == "furnished")           this.data.quotestring = "= £55";        if (this.data.services == "check-out" &&this.data.bedrooms =="2" && this.data.furnishing == "furnished")           this.data.quotestring = "= £60";       if (this.data.services == "check-out" &&this.data.bedrooms =="3" && this.data.furnishing == "furnished")           this.data.quotestring = "= £65";       if (this.data.services == "check-out" &&this.data.bedrooms =="4" && this.data.furnishing == "furnished")           this.data.quotestring = "= £70";       if (this.data.services == "check-out" &&this.data.bedrooms =="5" && this.data.furnishing == "furnished")           this.data.quotestring = "= £75";       if (this.data.services == "check-out" &&this.data.bedrooms =="6+" && this.data.furnishing == "furnished")           this.data.quotestring = "= £80";        if (this.data.services == "check-out" &&this.data.bedrooms =="1" && this.data.furnishing == "part furnished")           this.data.quotestring = "= £45";        if (this.data.services == "check-out" &&this.data.bedrooms =="2" && this.data.furnishing == "part furnished")           this.data.quotestring = "= £50";       if (this.data.services == "check-out" &&this.data.bedrooms =="3" && this.data.furnishing == "part furnished")           this.data.quotestring = "= £55";       if (this.data.services == "check-out" &&this.data.bedrooms =="4" && this.data.furnishing == "part furnished")           this.data.quotestring = "= £60";       if (this.data.services == "check-out" &&this.data.bedrooms =="5" && this.data.furnishing == "part furnished")           this.data.quotestring = "= £65";       if (this.data.services == "check-out" &&this.data.bedrooms =="6+" && this.data.furnishing == "part furnished")           this.data.quotestring = "= £70";        if (this.data.services == "check-out" &&this.data.bedrooms =="1" && this.data.furnishing == "unfurnished (except white goods)")           this.data.quotestring = "= £40";        if (this.data.services == "check-out" &&this.data.bedrooms =="2" && this.data.furnishing == "unfurnished (except white goods)")           this.data.quotestring = "= £45";       if (this.data.services == "check-out" &&this.data.bedrooms =="3" && this.data.furnishing == "unfurnished (except white goods)")           this.data.quotestring = "= £50";       if (this.data.services == "check-out" &&this.data.bedrooms =="4" && this.data.furnishing == "unfurnished (except white goods)")           this.data.quotestring = "= £55";       if (this.data.services == "check-out" &&this.data.bedrooms =="5" && this.data.furnishing == "unfurnished (except white goods)")           this.data.quotestring = "= £60";       if (this.data.services == "check-out" &&this.data.bedrooms =="6+" && this.data.furnishing == "unfurnished (except white goods)")           this.data.quotestring = "= £65";     document.getelementbyid("quote").innerhtml=this.data.quotestring;   },   init: function(){}    } quotemaker.init(); 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -