Solved
Can I lock / block a text field, once data is entered so that it can not be changed any more?
When using this "${rand://int/1:500}", a random number is generated in a text field. Now the issue is that subjects can still reenter a new value according to there preference. Is there a possibility to lock the text field once the random number appears. I need a text field since I am supposed to reference and compare the random number with a previously entered number in a way if it is smaller or bigger.
Other option could be to use HTML like this:
"
<button id="random" onclick="myFunction()"><b>You genereate a random number P</b></button>
<br>
<b>Ihr Marktpreis P für den Becher lautet:</b> <input type="number" id="number"><br><br>
<script>
function myFunction() {
document.getElementById("number").value = Math.floor((Math.random() * 500) + 1);
document.getElementById("number").disabled = true;
document.getElementById("random").disabled = true;
}
</script>
"
Can I compare subjects' previously entered number with the random one generated via HTML. How do I reference to an HTML code? Many Thanks for your support.
Best answer by TomG
> @Dafink said:
> Ok, thanks a lot Tom!
> Can I apply the "read only" command as javascript to image attached? The questions produce the random between 1: 500 and subjects are not allowed to change it. Do you know what I mean?
>
> (https://uploads-us-west-2.insided.com/qualtrics-us/attachment/ds_7lvht80fni3z.png "")
Yes:
```
Qualtrics.SurveyEngine.addOnload(function() {
jQuery("#"+this.questionId+" .InputText").prop("readonly", true);
});
```
View originalLeave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.