Note that there are some explanatory texts on larger screens.

plurals
  1. POStoring and retrieving data (in a button) to call back later
    primarykey
    data
    text
    <p>Sorry for my low level knowledge on this - I'm still new to javascript etc. Anyway, I've got a selector with randomized options. This is the html:</p> <pre><code>&lt;select id="patientSelect"&gt; &lt;option id="patient1"&gt;&lt;/option&gt; &lt;/select&gt; &lt;input type="button" id="bed1" value="Bed"&gt;&lt;/button&gt; &lt;input type="button" id="bed2" value="Bed 2"&gt;&lt;/button&gt; </code></pre> <p>And the javascript:</p> <pre><code>var count=Math.floor(Math.random()*61 + 10); var problem = new Array("Heart Attack", "Seizure", "Burns"); randprob = problem[Math.floor(Math.random() * problem.length)]; var age = Math.floor(Math.random() * 70 + 15); var counter=setInterval(timer, 1000); function timer(){ count--; var thisprob = randprob; var thisage = age; document.getElementById("patient1").innerHTML=thisprob + ", " + thisage + "ETA: " + count + " secs"; $('#patientSelect').change(function(){ $(".ui-btn").click(function(){ ... ? }); </code></pre> <p>So I'd like to put the current problem and age into the button I click (though the words on the button don't change), but also be able to click another button with different values and store those to retrieve later.</p> <p>Any help is appreciated, but if it's too much a direction on what to Google is also appreciated. Thanks. :)</p> <p><strong>Edit</strong> Thanks, great answers, but what would I do if I didn't know which button they clicked on? I might be storing data into #bed1 when they clicked on #bed2? Oh wait, that's where the (this) comes into play right?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload