Lets try to explain:
This code snippet works fine within agent code in passing a value to a script function:
local startpage = @" ...... include your html etc. ..... <button type='button' class='btn btn-default btn-lg' onclick='myJavaFunctionScriptName(1);'>Off</button> ";
however this does not work out:
local startpage = @" ...... include your html etc. ..... <button type='button' class='btn btn-default btn-lg' onclick='myJavaFunctionScriptName('a1');'>Off</button> ";
or this (which is what should work):
local startpage = @" ...... include your html etc. ..... <button type='button' class='btn btn-default btn-lg' onclick='myJavaFunctionScriptName(\\'a1\\');'>Off</button> ";
In both these cases, when inspecting html output through browser, it is showing the code as:
<button type="button" class="btn btn-default btn-lg" onclick="myJavaFunctionScriptName(" a1');'="">Off</button>
which is certainly not right. The html output I was expecting would have been:
<button type="button" class="btn btn-default btn-lg" onclick="myJavaFunctionScriptName('a1');">Off</button>