PDA

View Full Version : In JavaScript, Displaying Pressed button's Number and it's identification



ak47
08-09-2017, 04:54 AM
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()
{
Numbers(num);
num.toString();
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.">
</parameter>
</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"/>
</parameter>
</function>

6197

coothead
08-09-2017, 02:06 PM
Hi there ak47,


check out attachment to see a working example.

I have not coded anything for the two green buttons,
as I do not know what their functions are.



coothead

ak47
08-10-2017, 05:49 AM
Thank you.

ak47
08-10-2017, 05:52 AM
Is this script for an HTML page?

coothead
08-10-2017, 08:48 AM
Hi there ak47,



"Is this script for an HTML page?"
Yes, that is correct.


coothead