Jump to content

DoyleChris98

Members
  • Content Count

    37
  • Joined

  • Last visited

Community Reputation

0 Neutral

About DoyleChris98

  • Rank
    Newbie
  1. I have created a Websocket between my webpage and a application acting like a server on my computer. And the program is sending data though the Websocket, but i am trying to display it. When i open the page in the Chrome Developers Tools i get this. {"message":"SIMCONNECT_RECV_ID_SIMOBJECT_DATA","value":{"COM1_A":128.250000,"COM1_S":128.300003,"COM2_A":127.800003,"COM2_S":127.900002,"NAV1_A":108.500000,"NAV1_S":117.199997,"NAV2_A":110.599998,"NAV2_S":116.800003,"ADF1_A":284.000000,"ADF2_A":240.000000,"XPDR_A":4608}} Now im trying to figure out how to display the data into a div on my webpage. The old way i was displaying it was this way. Javascript jqXHR = $.getJSON("http://" + location.hostname + "/add_definition?definition_name=RADIO&name=COM1_A&PropertyName=COM ACTIVE FREQUENCY:1&UnitName=MHz&DatumType=FLOAT32", function(dane) {});jqXHR = $.getJSON("http://" + location.hostname + "/get?definition_name=RADIO", function(data){definition_data = data;});if (definition_data == undefined)return;var C1A = document.getElementById("COM1A");C1A.innerHTML = definition_data.COM1_A.toFixed(3); HTML <div class="DISP1" id="COM1A" type="button" name="COM1A" onclick="SETFREQ('com1_swap',1)">XXX.XXX</div> Im not sure how to display the data from the message into my page to display.
  2. Well i got it to work with the code you gave in post #9 jsfiddle. Next question can i make it so the to buttons act like radio buttons that shut off on when the other is clicked.
  3. No your code you gave me, when you pressed the test it change the other button. What i want is to change the button that you click. so what im reading on the internet is that i cant call a function in javascript, (i.e.:Function changeclass()) and have it run a function and change the class. I haft to use jquery toggleclass() outside and use it to look for a button press to change the class. When i can use a onclick() in html and have a javascript function change it.
  4. Well this is what i have this. function changeclass(){ $("#testid").click(function(){ $("#testid").removeClass("testclass").addClass("testclassclicked"); });var a = 2;var b = a + a;alert(;} I can get it to do the addition and display it but sometime the button changes color and others it dosen't. Is there a way to change it back.
  5. First its not that i want the button to just change the look i want it to run a function like add 2+2. Example. again function add(){ toggleclass() or whatever changes the class of the button to the clicked state. var a = 2; var b = a+a; alert (; that is what i want to do. As for javascript being inline, its the best way right now to test things. Once testing is done then i will create a separate file.
  6. well the example i put in the fiddle is just a example that i was trying to use. Im not sure on how to code it that is why I'm here trying to learn. I understand that things can't change till the page fully loaded. In the fiddle that you posted when you click the test button it changes the clicked example button, and I would like it to change the button that you click i.e. the test button. Next if i do use the code to change the button, can i still use the onClick() to run a function that is with the button click. Also need it to change back to the black background green text when you click it again, like turning a button on and off.
  7. I made a JSFiddle with some code but dosent work when clicked. The test button is the way it looks before clicked, then the clicked example is what it looks like after clicked. JSFiddle
  8. I have another thread in HTML working with it at http://w3schools.invisionzone.com/index.php?showtopic=52535. Looking into addClass() and removeClass() on the examples and i have a few questions. In the example they are changing the <p> of the HTML code. <p class="intro">This is a paragraph.</p> The code I'm using is this. <div><input type="button" class="RADIO" checked="checked" id="COM1TX" name="COMTX" value="COMTX1"><input type="button" class="RADIO1" id="COMRX" name="COMRX" value="COMRX"><input type="button" class="RADIO" id="COM2TX" name="COMTX" value="COMTX2"><input type="button" class="RADIO2" id="NAV1I" name="NAV1I" value="NAV1I"></div> I have buttons that need to act like Radio buttons and Check boxes and was going to try to use javascript to change the look of them onclick(), and run a function associated with the button. Instead of using <p> or <div> can you use the ID for the $("p:last").removeClass("radiounclicked").addClass("radioclicked"); ID COM1TX and COM2TX are radio buttons where one turns on and the other shuts off. And the rest are like Check Boxes where you can turn them on and off. Here is the JSFiddle for it and the Fullscreen JSFiddle.
  9. I was wondering if javascript or jquery could change the look of a CSS class in a function called by a onclick(). For example I have a #first and also a .unclicked and .clicked. And i have a input type="button" id="first" class="unclicked" onclick="function()". function(){ change class from unclicked to clicked on first then some other code } Inside the function how do i change the class from unclicked to clicked. I know you haft to use the document.getid(first).style, but I'm not sure how to get the function to change it.
  10. The program uses a a webpage function to set items. For example in the picture above Pad2 in post #15 if you click one of the XXX.XXX it calls a function. <div class="DISP2" id="COM1S" name="COM1S" onclick="CONVERT(this)">XXX.XXX</div> Function function CONVERT(event){ FREQ = parseFloat(document.getElementById("INPUT").value); FREQ = FREQ.toFixed(2); var n1 = FREQ.substr(0, FREQ.indexOf(".")); n1 = n1.substr(n1.length-2); var n2 = FREQ.substr(FREQ.indexOf(".")+1,2); var bcd = (parseInt(n1.charCodeAt(0) - 0x30 )<<12) + (parseInt(n1.charCodeAt(1) - 0x30 )<<8) + (parseInt(n2.charCodeAt(0) - 0x30 )<<4) + parseInt(n2.charCodeAt(1) - 0x30 ); document.getElementById("INPUT").value = ""; SETFREQ(event.id, bcd);}function SETFREQ(event, value){ $.ajaxSetup({ cache: false }); // nedeed for IE8 $.support.cors = true; // required if the script is local $.ajaxSetup({ async: false }); var jqXHR = $.getJSON("http://" + location.hostname + "/set_event_value?name=" + event + "&value=" + value, function(dane){}); $.ajaxSetup({ async: true }); } Now with the Buttons i will need a talk back to change the state in the webpage if its changed in FSX, but that is something ill work on later. I know i can change the state of the button with Jquery, but i was seeing if i could use Radio Buttons and Check Boxes.
  11. Alright i through together what it should look like but function isn't all the way there and i have attached a jsfiddle of it to. In the fiddle i use focus to show the change when active. COM 1 Tx and COM 2 Tx (with yellow to ID them in the picture) should act like Radio Buttons turn on on the other shuts off. The rest should act like Check Boxes to turn on and off. Later they will be calling a function when clicked but thats later. https://jsfiddle.net/zxo0myah/ Fullscreen https://jsfiddle.net/zxo0myah/embedded/result/
  12. Ok here is the story. Theirs a program that comes with Microsoft Flight Simulator (FSX) called Simconnect which you can right C++ programs to access FSX though Simconnect. A person made a program that accesses Simconnect through a webpage called Websimconnect (Webpage <-> Websimconnect <-> Simconnect <-> FSX). Things that you can do is change Radios, Display your location on google maps from FSX, and many other things. What i'm trying to create is a LCD radio display that you can enter the Frequency and change radios that shows up on a website. I have the keypad layout done but trying to add a few more buttons. The buttons turn on and off the Radios, Which act like a Checkboox and radio buttons. Buttons-2 picture shows the buttons inside FSX, with COM 1 Active COM 2 off with everything else. Buttons-3 picture shows COM 2 active which shuts off COM 1 (like a Radio Button) and the rest turn on and stay on like a check box. Pad2 shows the way i would like it to look, where the buttons i want to add are on the left side. And all the buttons change background and text color when clicked. Hopefully that explains it enough.
  13. Anybody with a idea on this. I wa able to get the Radio Buttons to move but i cant get the checkboxes to Style and also i cant figure out the location with the relative setting. I dont know what the location is relative to.
  14. Its used for a game Microsoft Flight Simulator, its for entering radio frequencies from a webpage. you press the keypad buttons (0-9, ., C, to enter the frequency in the input box then press the bottom XXX.XXX to enter the frequency, then it enters it into FSX. Also i can open the ATC window with the small buttons next to the input box. And the buttons that i need the Radio and Check Boxes for turn on and shut off the radios. The XXX.XXX show up because i dont have FSX running at the time of the picture. I was using the DIV tags because it was either here or at stackoverflow that somebody told me to use the DIV tag to make the grid layout.
  15. Well your half right, the color when activated is right. But I would like COM and COM2 set up and radio buttons, so whe you click on COM it lights up but when you click COM 2, COM 2 lights up and COM turns off. Ill attach a picture of how and where i want them to go. If you look at the picture the line that the arrow is pointing at its at 840px from the left. That is where the buttons will line up from the left and the height from the top will be solved when when the left is figured out. and in the picture there is COM 1 Tx, COM 1,2 Rx, COM 2 Tx. Where COM 1 Tx and COM 2 Tx will be radio buttons and COM 1,2 Rx is like a checkbox.
×
×
  • Create New...