Many of the javascripts that I work with on conventional web-pages use the general form of an input element of some type, a button to call the javascript and a separate output element of some type, frequently a textarea. Generally the javascript pulls in data from the input element and pushes the results to a different output element. TiddlyWiki’s handling of javascript seems to be predicated on the idea that the calling element gathers the input from wherever, passes the parameters to the javascript which then passes the results back to the calling element.
Those aren’t the same and I’ve reworked a number of scripts to accomplish the same result. So far most of them have worked if they are a bit clunky. I did one where, instead of having the script pull the input parameters once, do the calculation in a loop and have the script push the answer out 140 times, I had 140 separate calls to the script that did the calculation once. That didn’t seem like the right way to go so I’ve been revisiting what I know about Javascript. When I stumbled into the routine that became what is below, I saw several pieces of what I wanted to do. The script has no parameters as such, pulls the input from one html element, does something with it, and pushes the result out to two other html elements. That is ultimately what I want to accomplish. That is what I haven’t mastered in TiddlyWiki. I don’t understand why it doesn’t work. This works in a conventional html web-page but I haven’t been able to make it work in TiddlyWiki.If you play with this, you'll note that though you clicked the button, the selected area of the textarea was still active, even though the textarea did lose the focus. <!DOCTYPE html> > <html> > <body> > > <textarea rows="4" cols="50" id="myTextarea"> > 342 Alvin Road > Houston, Texas > USA > Earth > Solar System</textarea> > > <textarea rows="4" cols="50" id="myTextarea2"> > Nothing here</textarea> > > <p>Click the button to copy the highlighted content to myTextarea2.</p> > > <button type="button" onclick="myFunction()">Copy highlighted</button> > > <p id="demo">Nothing yet</p> > > <script> > function myFunction() { > var txt = document.getElementById("myTextarea"); > var start = txt.selectionStart; > var finish = txt.selectionEnd; > var sel = txt.value.substring(start, finish); > document.getElementById("myTextarea2").value = sel; > document.getElementById("demo").innerHTML = sel+" was extracted from > Textarea 1 and pushed into Textarea 2" > } > </script> > > </body> > </html> > -- You received this message because you are subscribed to the Google Groups "TiddlyWiki" group. To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+unsubscr...@googlegroups.com. To post to this group, send email to tiddlywiki@googlegroups.com. Visit this group at http://groups.google.com/group/tiddlywiki. For more options, visit https://groups.google.com/d/optout.