DoyleChris98 Posted January 16, 2015 Share Posted January 16, 2015 I am making a website to get Radio frequencies from Microsoft Flight Simulator through Simconnect on my computer. I would like to get the FREQ from FSX and convert them to 0, 1, 2, 3 decimal places. Ill give a example below and explain it. I want to set COM1 Freq to 3 decimal places 130.250 but where do i put the toFixed(3) at in the code. Gets COM1 Active frequency from FSX <SCRIPT src="../jquery-1.7.1.js"></script><script src="sprintf.js"></script> <script type="text/javascript"></script> function body_onload() {var jqXHR;jqXHR = $.getJSON("http://" + location.hostname + "/add_definition?definition_name=RADIO&name=COM1_A&PropertyName=COM ACTIVE FREQUENCY:1&UnitName=MHz&DatumType=FLOAT32", function(data) {});} Sets variable for it function get_values() {var C1A = document.getElementById("COM1_AD");C1A.innerHTML = definition_data.COM1_A;} Displays the data <BODY onload="body_onload()"><P>COM 1 Active is: <SPAN id="COM1_AD"></SPAN></P></BODY> Link to comment Share on other sites More sharing options...
Ingolme Posted January 16, 2015 Share Posted January 16, 2015 I assume definition_data.COM1_A is the variable with the number you want. You can just change the line to C1A.innerHTML = definition_data.COM1_A.toFixed(3); If that doesn't work, then it's because it's not a number and you'll have to cast it to a number first: C1A.innerHTML = Number(definition_data.COM1_A).toFixed(3); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now