Jump to content

In JavaScript, Displaying Pressed button's Number and it's identification

Recommended Posts

Here my question is how to print/display the numbers from pressed buttons(as shown in figure) using JavaScript. However, here I am working on a device and we have to control it from JavaScript. Below I have mentioned my code(.js) snippet:

// Numbers function
function Numbers(cmd)
System.Print("Command Sent is: "+cmd);
var num = cmd;
System.Print("Button pressed is: "+num);

// Displaying Numbers
function Display()
dbgPrint("Displaying number: " + num);

And parameters for this function I am passing from some other file(.xml) as standard.

<function name="Display" export="Display">
<parameter name="display" type="string" description="Drag and drop this for clear-button function.">
<function name="Numbers" export="Numbers">
<parameter name="command" type="mcinteger" description="Drag and drop this command for Numbers.">
<choice name="1" value="1"/>
<choice name="2" value="2"/>
<choice name="3" value="3"/>
<choice name="4" value="4"/>
<choice name="5" value="5"/>
<choice name="6" value="6"/>
<choice name="7" value="7"/>
<choice name="8" value="8"/>
<choice name="9" value="9"/>
<choice name="0" value="0"/>



Edited by ak47
Here I have uploaded one more image, I hope that this will give you full clarity about my project.
Link to post
Share on other sites

One problem with that code is that the variable num is not defined inside the Display function, so you're passing an undefined value to Numbers.  How do you call those functions from the interface though, how are those buttons and the click handlers defined?

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...