--
You received this message because you are subscribed to the Google Groups "LIONESS Lab help and discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lioness-lab...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/lioness-lab/dfa0625a-1397-4f39-a2a3-4ccaba8baf00n%40googlegroups.com.
Steven and I just found an odd behavior. At least it appears odd to me...Steven figured out he could manipulate the display of a <div> directly on the same screen/stage using the following code.In the top JS element, he uses:function button1() {
document.getElementById("Mess").innerHTML = "Rand # "+Math.random();
return false; // I don't seem to need this in chrome, but it may be for another browser
}Then in the text box he uses:<button onclick="button1(); return false;" >Continue.</button>
<div id="Mess"></div>This is interesting as it's working fine! The <div id=Mess"> is shown on the screen and on each button click the random number changes. So it seems that the click of the button invokes the function button() as it should.It seems that all the buttons I have used in the text box so far worked fine (I have no error message or warning), and they all do the same thing when I declare the function as Steven did.My button in the text box currently looks like this:<input id="myButton1" type="button" value="Continue." onclick="button1();">But it appears that using the document.getElementbyId("Mess")innerHTML the way it's coded here is a very local output/display solution.The buttons still don't seem to create or manipulate variables with the record() or setValue() functions, even if I put the setValue() inside the button().Moreover, the button() doesn't even seem to execute the next_part =1; of the code inside the button().It seems that for some reason the functions invoked in the HTML text box don't interact with the pre-coded LIONESS functions or the database at all.Could that be? Or what's going on?It's hard to improve anything without any error/warning message displayed in the console.
Thanks for your help!Thomas
On Monday, 5 April 2021 at 14:47:05 UTC+12 Thomas Dudek wrote:Dear LIONESS team, dear community,If anyone else can help us with this, that would be great.Both Steve and I would like to find a way to easily code a button that executes a function that saves some variables to the database, but the button should not change to a new stage, nor should it do anything else.Hope someone has a good idea.My approach currently is as follows:1. Define the function in a Javascript element at the top of the stage. Like so
function button() {var next_part = 1;setValue('var1', var1 ); //These variables are recorded using, e.g., record('var1', null) in a previous stage.setValue('var2', var2 );}2. Create a text element with a button, as follows<input onclick="button()" type="button" value="Continue." id="myButton"><br><script>button();</script>Please click this button to see the next part.With this code, I see the button just fine, I can click the button, but nothing happens. Why?Thanks for your help,Thomas
To view this discussion on the web, visit https://groups.google.com/d/msgid/lioness-lab/78269c8c-a82c-480f-936d-1e01fb40886bn%40googlegroups.com.