Hi
I don't really understand what you mean by "How to pass array from html to Droidscript" nor "Passing parameters from HTML to Droidscript".
I think what you have is this scenario
1. You have a native DroidScript app which is your main app.
2. In your main app, you have a webview which is your html app which we know that javascript in DS WebView runs in another thread.
3. You need to pass array from your main app to your html in the webview.
If I get it right, then here's the short code snippet for you.
In your mainApp.js file
function OnStart() {
lay = app.CreateLayout( "linear", "VCenter,FillXY" )
web = app.AddWebView(lay, 0.9, 0.8);
web.SetOnProgress(OnProgress);
web.LoadUrl("myWeb.html");
app.AddLayout( lay )
}
function OnProgress(v) {
// make sure the html is fully loaded
if(v == 100) {
var arrData = [1, "Some text", true];
web.Func("myHtmlFunction", arrData);
}
}
In your myWeb.html file
<html>
<head>
<script src='file:///android_asset/app.js'></script>
<title>Hello World!</title>
<script>
function myHtmlFunction(arrData) {
console.log(arrData);
}
</script>
</head>
<body>
<p>Hello World!</p>
</body>
</html>
Alternatively, if you want to pass data from the webView html to the main app, here is the code snippet
In your mainApp.js file
function OnStart() {
lay = app.CreateLayout( "linear", "VCenter,FillXY" )
web = app.AddWebView(lay, 0.9, 0.8);
web.LoadUrl("myHtml.html");
app.AddLayout( lay )
}
function myMainFunc(arrData) {
console.log(arrData);
}
In your myWeb.html file
<html>
<head>
<script src='file:///android_asset/app.js'></script>
<title>Hello World!</title>
<script>
function OnStart() {
var arrData = [1, "Some text", true];
app.Func("myMainFunc", arrData);
}
</script>
</head>
<body onload="app.Start()">
<p>Hello World!</p>
</body>
</html>
Regards
Jumar