Everything posted by Varcoe
-
Need some quick jQuery Help.. (Form Calculations)
There was two erros i found: 1) You tryed storing the values in arrays rather then objects 2) The object for red network had no options it looks like you named them bandwidth // Dropdown "value" prices var colosize = {}; colosize["14"]=229; colosize["12"]=339; colosize["11"]=699; colosize["31"]=2000; var power = {}; power["1c16"]=0; power["1c24"]=135; power["2c16"]=135; power["2c24"]=250; var bandwidth = {}; bandwidth["100"]=0; bandwidth["200"]=99; bandwidth["500"]=499; bandwidth["1000"]=999; var rednetwork = {}; rednetwork["none"]=0; rednetwork["100"]=99; rednetwork["1000"]=199; var ipv4 = {}; ipv4["8"]=0; ipv4["16"]=8; ipv4["32"]=24; ipv4["64"]=56; ipv4["128"]=120; var kvm = {}; kvm["0"]=0; kvm["1"]=25; kvm["2"]=50; kvm["3"]=75; kvm["4"]=100; kvm["5"]=125; kvm["6"]=150; kvm["7"]=175; kvm["8"]=200; kvm["9"]=225; kvm["10"]=250; kvm["20"]=500; kvm["40"]=1000; var manage = {}; manage["0"]=0; manage["1"]=50; manage["2"]=100; manage["3"]=150; manage["5"]=250; manage["10"]=500; manage["20"]=1000; manage["40"]=1500; //This function finds the price based on the //drop down selection function getcolosizePrice() { var colosizePrice=299; //Get a reference to the form var theForm = document.forms["order-form"]; //Get a reference to the select var selectedcolosize = theForm.elements["colosize"]; //set Price equal to value user chose colosizePrice = colosize[selectedcolosize.value]; //finally we return return colosizePrice; } function getpowerPrice() { var powerPrice=0; //Get a reference to the form var theForm = document.forms["order-form"]; //Get a reference to the select var selectedpower = theForm.elements["power"]; //set Price equal to value user chose powerPrice = power[selectedpower.value]; //finally we return return powerPrice; } function getbandwidthPrice() { var bandwidthPrice=0; //Get a reference to the form var theForm = document.forms["order-form"]; //Get a reference to the select var selectedbandwidth = theForm.elements["bandwidth"]; //set Price equal to value user chose bandwidthPrice = bandwidth[selectedbandwidth.value]; //finally we return return bandwidthPrice; } function getrednetworkPrice() { var rednetworkPrice=0; //Get a reference to the form var theForm = document.forms["order-form"]; //Get a reference to the select var selectedrednetwork = theForm.elements["rednetwork"]; //set Price equal to value user chose rednetworkPrice = rednetwork[selectedrednetwork.value]; //finally we return return (rednetworkPrice > 0?rednetworkPrice:0); } function getipv4Price() { var ipv4Price=0; //Get a reference to the form var theForm = document.forms["order-form"]; //Get a reference to the select var selectedipv4 = theForm.elements["ipv4"]; //set Price equal to value user chose ipv4Price = ipv4[selectedipv4.value]; //finally we return return ipv4Price; } function getkvmPrice() { var kvmPrice=0; //Get a reference to the form var theForm = document.forms["order-form"]; //Get a reference to the select var selectedkvm = theForm.elements["kvm"]; //set Price equal to value user chose kvmPrice = kvm[selectedkvm.value]; //finally we return return kvmPrice; } function getmanagePrice() { var managePrice=0; //Get a reference to the form var theForm = document.forms["order-form"]; //Get a reference to the select var selectedmanage = theForm.elements["manage"]; //set Price equal to value user chose managePrice = manage[selectedmanage.value]; //finally we return return managePrice; } function calculateTotal() { //Here we get the total price by calling our function //Each function returns a number so by calling them we add the values they return together var totalPrice = getcolosizePrice() + getmanagePrice() + getkvmPrice() + getipv4Price() + getrednetworkPrice() + getbandwidthPrice() + getpowerPrice() + getcolosizePrice(); console.log(getrednetworkPrice()); //display the result var divobj = document.getElementById('totalPrice'); divobj.style.display='block'; divobj.innerHTML = "$"+totalPrice; } function hideTotal() { var divobj = document.getElementById('totalPrice'); divobj.style.display='none'; } Thank you! The arrays weren't the problem though it was rednetwork -.- I had the script working before I added all the options - can't believe I overlooked that. Anyways it is fixed now, I'm still using arrays are objects better?
-
Need some quick jQuery Help.. (Form Calculations)
I tried and tried, I just can't seem to find the bug in this code. Its a simple form price calculator. When the user changes the select box the price is supposed to update by getting the selected option and get the price from an array. jQuery: // Dropdown "value" prices var colosize = new Array(); colosize["14"]=229; colosize["12"]=339; colosize["11"]=699; colosize["31"]=2000; var power = new Array(); power["1c16"]=0; power["1c24"]=135; power["2c16"]=135; power["2c24"]=250; var bandwidth = new Array(); bandwidth["100"]=0; bandwidth["200"]=99; bandwidth["500"]=499; bandwidth["1000"]=999; var rednetwork = new Array(); bandwidth["none"]=0; bandwidth["100"]=99; bandwidth["1000"]=199; var ipv4 = new Array(); ipv4["8"]=0; ipv4["16"]=8; ipv4["32"]=24; ipv4["64"]=56; ipv4["128"]=120; var kvm = new Array(); kvm["0"]=0; kvm["1"]=25; kvm["2"]=50; kvm["3"]=75; kvm["4"]=100; kvm["5"]=125; kvm["6"]=150; kvm["7"]=175; kvm["8"]=200; kvm["9"]=225; kvm["10"]=250; kvm["20"]=500; kvm["40"]=1000; var manage = new Array(); manage["0"]=0; manage["1"]=50; manage["2"]=100; manage["3"]=150; manage["5"]=250; manage["10"]=500; manage["20"]=1000; manage["40"]=1500; //This function finds the price based on the //drop down selection function getcolosizePrice() { var colosizePrice=299; //Get a reference to the form var theForm = document.forms["order-form"]; //Get a reference to the select var selectedcolosize = theForm.elements["colosize"]; //set Price equal to value user chose colosizePrice = colosize[selectedcolosize.value]; //finally we return return colosizePrice; } function getpowerPrice() { var powerPrice=0; //Get a reference to the form var theForm = document.forms["order-form"]; //Get a reference to the select var selectedpower = theForm.elements["power"]; //set Price equal to value user chose powerPrice = power[selectedpower.value]; //finally we return return powerPrice; } function getbandwidthPrice() { var bandwidthPrice=0; //Get a reference to the form var theForm = document.forms["order-form"]; //Get a reference to the select var selectedbandwidth = theForm.elements["bandwidth"]; //set Price equal to value user chose bandwidthPrice = bandwidth[selectedbandwidth.value]; //finally we return return bandwidthPrice; } function getrednetworkPrice() { var rednetworkPrice=0; //Get a reference to the form var theForm = document.forms["order-form"]; //Get a reference to the select var selectedrednetwork = theForm.elements["rednetwork"]; //set Price equal to value user chose rednetworkPrice = rednetwork[selectedrednetwork.value]; //finally we return return rednetworkPrice; } function getipv4Price() { var ipv4Price=0; //Get a reference to the form var theForm = document.forms["order-form"]; //Get a reference to the select var selectedipv4 = theForm.elements["ipv4"]; //set Price equal to value user chose ipv4Price = ipv4[selectedipv4.value]; //finally we return return ipv4Price; } function getkvmPrice() { var kvmPrice=0; //Get a reference to the form var theForm = document.forms["order-form"]; //Get a reference to the select var selectedkvm = theForm.elements["kvm"]; //set Price equal to value user chose kvmPrice = kvm[selectedkvm.value]; //finally we return return kvmPrice; } function getmanagePrice() { var managePrice=0; //Get a reference to the form var theForm = document.forms["order-form"]; //Get a reference to the select var selectedmanage = theForm.elements["manage"]; //set Price equal to value user chose managePrice = manage[selectedmanage.value]; //finally we return return managePrice; } function calculateTotal() { //Here we get the total price by calling our function //Each function returns a number so by calling them we add the values they return together var totalPrice = getcolosizePrice() + getmanagePrice() + getkvmPrice() + getipv4Price() + getrednetworkPrice() + getbandwidthPrice() + getpowerPrice() + getcolosizePrice(); //display the result var divobj = document.getElementById('totalPrice'); divobj.style.display='block'; divobj.innerHTML = "$"+totalPrice; } function hideTotal() { var divobj = document.getElementById('totalPrice'); divobj.style.display='none'; } Although I'm pretty certain its a jquery issue, code is a bit long so i pasted the html code here: http://pastebin.com/bQJ4FBkA Online: http://varcoedesign.com/work/fiberhub/order.html As you can see the price says $NaN Any help within the next 24 hours would be greatly appreciated! I don't ask for help often, I usually figure it out but jquery is not my strong suit - i'm still a novice with jquery.
-
How to ruin a website
I know exactly how this can be.. Client's aren't "Design Savvy" so they don't understand what is ruining the website, they think it looks good because its what they want. Just like a designer will like his way better because he likes it (in most cases it probably is). What I do is just say something like "I don't recommend we do that because it won't look so good (and explain why), but if you insist I will make the change". That blog post is pretty awesome though.