J jhagerup Member Licensed User Longtime User Aug 23, 2015 #1 I am trying to get the id's for all textarea in a table. Code: Copy Dim f As Future f = ws.EvalWithResult("return $(arguments[0]).attr(""id"")", Array As Object("textarea")) Log(f.Value) returns the first id correct, but I can't figure out how to get all id's Code: Copy Dim f2 As Future ws.Eval("$(arguments[0]).each(function(){alert( $(this).attr(""id""))})", Array As Object("textarea")) shows alerts with the correct id's, but when i try with Code: Copy Dim f3 As Future f3 = ws.EvalWithResult("return $(arguments[0]).each(function(){return $(this).attr(""id"")})", Array As Object("textarea")) I get a "strange" map with unrecognizable data like: {11={}, 12={}, 13={}, prevObject={0={location={search=, hostname=localhost, protocol=http:..... Please help
I am trying to get the id's for all textarea in a table. Code: Copy Dim f As Future f = ws.EvalWithResult("return $(arguments[0]).attr(""id"")", Array As Object("textarea")) Log(f.Value) returns the first id correct, but I can't figure out how to get all id's Code: Copy Dim f2 As Future ws.Eval("$(arguments[0]).each(function(){alert( $(this).attr(""id""))})", Array As Object("textarea")) shows alerts with the correct id's, but when i try with Code: Copy Dim f3 As Future f3 = ws.EvalWithResult("return $(arguments[0]).each(function(){return $(this).attr(""id"")})", Array As Object("textarea")) I get a "strange" map with unrecognizable data like: {11={}, 12={}, 13={}, prevObject={0={location={search=, hostname=localhost, protocol=http:..... Please help
rwblinn Well-Known Member Licensed User Longtime User Aug 23, 2015 #2 Hi, try following JavaScript Function in Index.html Script section Code: Copy function getids(){ var ids = []; var elements = document.getElementsByTagName("textarea"); for(var i=0;i<elements.length;i++){ ids.push(elements[i].id) }; return ids; }; B4J Code (uses Websockets) Dim f As Future = ws.RunFunctionWithResult("getids", Null) Dim l As List = f.value For i = 0 To l.Size - 1 Log(l.Get(i)) Next Example project attached. The getids function can be extended by using a parameter of the element to get id's from. Attachments WebAppGetIDs.zip WebAppGetIDs.zip 5.7 KB · Views: 578 Upvote 0
Hi, try following JavaScript Function in Index.html Script section Code: Copy function getids(){ var ids = []; var elements = document.getElementsByTagName("textarea"); for(var i=0;i<elements.length;i++){ ids.push(elements[i].id) }; return ids; }; B4J Code (uses Websockets) Dim f As Future = ws.RunFunctionWithResult("getids", Null) Dim l As List = f.value For i = 0 To l.Size - 1 Log(l.Get(i)) Next Example project attached. The getids function can be extended by using a parameter of the element to get id's from.
J jhagerup Member Licensed User Longtime User Aug 24, 2015 #3 Thanks. Just what I needed. Sometimes jQuery is "a bridge too far" ;-) Upvote 0