BTU Calculator Creation

Has anyone ever created a BTU Calculator through their forms? I’m in the middle of creating a form now and I am trying to get it to calculate in stages

export function crms_click ( event ) {

let #rmw = Number $w ( “#rmw” ). value );
let #rml = Number $w ( “#rml” ). value );
let #rmh = Number $w ( “#rmh” ). value );

$w : “#rms” ) _text = ( #rmh * #rml * #rmh ) _toString :);

}

So what I have done which is not working is I have 3 options to start with
Room Width #rmw / Room Height #rmh / Room Length #rml which is text boxes that have been set to numbers

I then have another text box which is also set Number but is read only to give me the total Cubic Meter of the room #rms

Last part to this is the calculate button which is ID: #crms

None of what I have done above seems to be working and when I go to preview and test in the Dev section below this is the error I recieve:

public/pages/rweu2.js: Unexpected reserved word ‘let’. (16:0) 14 | export function crms_click(event) { 15 | // This function was added from the Properties & Events panel. To learn more, visit Velo: Working with the Properties & Events Panel | Help Center | Wix.com > 16 | let #rmw = Number $w(“#rmw”).value); | ^ 17 | let #rml = Number $w(“#rml”).value); 18 | let #rmh = Number $w(“#rmh”).value); 19 |

WRONG!

let #rmw

RIGHT!

let rmw

Totaly WRONG !

$w:"#rms")_text =(#rmh*#rml*#rmh)_toString:);

RIGHT !

let rms = String(rmw+rlm+rmh);
$w("#rms").text = rms;

Hi Ninja
Thank you kindly for replying :slight_smile:

I have gone and changed as suggested and unfortunately, nothing has changed in regards to calculations. Please see the formula and below listed error, I believe and thank you once again for replying

$w . onReady ( function () {

});

export function crms_click ( event ) {
let rmw = Number $w ( “#rmw” ). value );
let rml = Number $w ( “#rml” ). value );
let rmh = Number $w ( “#rmh” ). value );

let rms = String ( rmw + rlm + rmh );
$w ( “#rms” ). text = rms ;

}

public/pages/rweu2.js: Missing semicolon. (8:16) 6 | 7 | export function crms_click(event) { > 8 | let rmw = Number $w(“#rmw”).value); | ^ 9 | let rml = Number $w(“#rml”).value); 10 | let rmh = Number $w(“#rmh”).value); 11 |

Also I am new to wix and its current setup and have been trying to follow a Youtube tutorial which is obviously not helping me much its called calculating fields using wix code from wixshow. com

Still missing a —> ( <— here…

let rmw = Number($w("#rmw").value);
let rml = Number($w("#rml").value);
let rmh = Number($w("#rmh").value);

RESULT:

$w.onReady(function(){
	$w('#crms').onClick(()=>{
		let rmw = Number($w("#rmw").value);
		let rml = Number($w("#rml").value);
		let rmh = Number($w("#rmh").value);
		
		let rms = String(rmw+rlm+rmh); 
		$w("#rms").text = rms;
	});
});

You have big difficulties with the SYNTAX. You will have to learn more JS-Basic-coding.

@russian-dima Most definitely I do. This is the first experience I have ever had with Wix as I have used Wordpress Mainly for any online sites ever used.

I have used your specific code and while it has thrown up any errors it however has not given me the total sum which I can assume is probably because I am using a Text input Box cms ? ( As seen in photo of Room Size Calculated)

@terry68074

Well, looking at your shown PIC and your whole project.

Question-1: → Shouldn’t it be → a * b * c ? and not —> a + b + c ?
Question2:—> You said, there were no ERRORs, but on the PIC you can see still ERRORs.

Did you add a wrong PIC ?

To check your own CODE → USE → CONSOLE-LOG.

$w.onReady(function(){ 	
    $w('#crms').onClick(()=>{
        let rmw = Number($w("#rmw").value); console.log("Room-Width: ",rmw); 
        let rml = Number($w("#rml").value); console.log("Room-Length: ",rml); 
        let rmh = Number($w("#rmh").value); console.log("Room-Heihgt: ",rmh); 
        let rms = String(rmw*rlm*rmh)+" cm³"; console.log("Room-Result: ",rms); 
        $w("#rms").text = rms; 
    });
});

Also check if all your element-IDs are correct —> “#rmw”, “#rmh”, “#rml”, “#rms

BTW: How to use the CONSOLE? → When using google-chrome → Press F-12 and navigate to —> CONSOLE.

Is there a basic guide available to work from when it comes to doing calculations like this?

To learn about programming with Velo, read the following articles that will help you start working with Velo:

For a very simple example of using user inputs for calculations, see the Attendance Fees example.