imaaxx Posted October 19, 2004 Share Posted October 19, 2004 Hello I have looked in the forums and found very little about adding sq. ft. calculations to our cart check out. I am building a site for a flooring company we need the ability to calculate square footages for example: The person knows how many square feet of a product they need so they can just type in the amount to the cart and have it add the price for them of the product they have selected. or they don?t know the square footage of a room but they have the room dimensions ?length x width? then have the cart do the calculations ? amount ? x ?price?. I would like to have both options on my pages. Is there a contribution for this? Unfortunately I am not a PHP programmer, so any help would be appreciated. thanks in advance ?. Link to comment Share on other sites More sharing options...
imaaxx Posted October 20, 2004 Author Share Posted October 20, 2004 Hello I have looked in the forums and found very little about adding sq. ft. calculations to our cart check out. I am building a site for a flooring company we need the ability to calculate square footages for example: The person knows how many square feet of a product they need so they can just type in the amount to the cart and have it add the price for them of the product they have selected. or they don?t know the square footage of a room but they have the room dimensions ?length x width? then have the cart do the calculations ? amount ? x ?price?. I would like to have both options on my pages. Is there a contribution for this? Unfortunately I am not a PHP programmer, so any help would be appreciated. thanks in advance ?. <{POST_SNAPBACK}> wow i have been searching on this and not getting very far :( how is it possible this has not come up before?? Link to comment Share on other sites More sharing options...
thadon101 Posted October 20, 2005 Share Posted October 20, 2005 Have you figured out how to calculate sq. ft. in your cart yet. If so can you please post or send me the code you used or point me in the right direction. Thanks in advance Link to comment Share on other sites More sharing options...
bobg7 Posted October 20, 2005 Share Posted October 20, 2005 I have this script that may help. Add this to the head of the page: <script LANGUAGE="JavaScript"> <!-- Begin var formulas = new Array() formulas["square"] = "Math.pow(num_one,2)"; formulas["rectangle"] = "num_one * num_two" formulas["parallelg"] = "num_one * num_two"; formulas["triangle"] = "num_one * num_two / 2"; function getCheckedNum() { var selected; for(var loop=0;loop<window.document.convert.to_which.length;loop++) { if(window.document.convert.to_which[loop].checked == true) { selected = loop; } } return selected; } function calculate(num_one,num_two) { if((isNaN(parseInt(num_one))) || (isNaN(parseInt(num_two)))) { alert('You must enter numbers'); return; } var selected_index = getCheckedNum(); var selected_value = window.document.convert.to_which[selected_index].value; if((selected_value == "square") && (num_one != num_two)) { alert('Your square is not square'); return; } formula = formulas[selected_value]; var answer = eval(formula); alert(answer); } // End --> </script> Add this to the body of the page: <form name="convert"> Find the area of a:<br> <input type="radio" checked="yes" name="to_which" value="square">square<br> <input type="radio" name="to_which" value="rectangle">rectangle<br> <input type="radio" name="to_which" value="parallelg">parallelogram<br> <input type="radio" name="to_which" value="triangle">triangle<br> The length is: <input type="text" size="5" name="base"> The width is: <input type="text" size="5" name="height"><br> <input type="button" value="calculate" onclick="calculate(window.document.convert.base.value,window.document.convert.height.value);"> </form> Hope it helps and I copied it correctly Installed Contributions: CCGV, Close Popup, Dynamic Meta Tags, Easy Populate, Froogle Data Feeder, Google Position, Infobox Header Entire Row, Live Support for OSC, PayPal Seal with CC images, Report_m Sales, Shop by Price Revised, SQL Updater, Who's Online Enhancement, Footer, GNA EP Assistant and still going. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.