How to test for the absence of a response in inline_javascript
Hi there,
I'm writing some inline_script code whether different things should happen depending on whether a response has been collected or not. However, I'm having some trouble working out what the condition should be set to...
I tried:
If (vars.response)=None {
If (vars.response)="None" {
If (vars.response)="" {
but to no avail...
Just wondering what the correct way is. If there isn't one in Javascript, I'll got for plan B: create two sketchpads, each with its distinct duration, and use "Run if" conditions to run one or the other depending on whether [response]=None or [response]!=None...
Any hint much appreciated! Thanks!
Fabrice.


Comments
Hi @Fab ,
For this if-statement, where you compare two values, you will need to use the "equal to" operator:
if (vars.response == "None"){ // Code block }Does that solve it?
Cheers,
Lotje
Did you like my answer? Feel free to

Hi @lvanderlinden,
Yes! Awesome! 😀
Gosh... "=="... Haven't worked my head around Javascript's ways... I feel so embarrassed now 😉
Thanks for this!
Cheers,
Fabrice.
I knew you'd say that, but these things happen to the best ;-) Does it work now?
Did you like my answer? Feel free to

Yes, perfectly, thanks!
F.