Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

HTML/ JavaScript program for input

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 1 month ago #149555 by tpartner
Replied by tpartner on topic HTML/ JavaScript program for input
If you want to include the dashes and spaces in your data, simply use a short-text type question instead of a numeric type.

If you want to remove the dashes and spaces in your data, replace both instances of this:
Code:
thisInput.val(document.getElementById('Zahlenanzeige').innerHTML);
with this:
Code:
thisInput.val(document.getElementById('Zahlenanzeige').innerHTML.replace(/\s+/g, '').replace(/-/g, ''));

If you want to replace the dashes and spaces with commas in your data, replace both instances of this:
Code:
thisInput.val(document.getElementById('Zahlenanzeige').innerHTML);
with this:
Code:
thisInput.val(document.getElementById('Zahlenanzeige').innerHTML.replace(/\s+/g, '').replace(/-/g, ','));

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: Spix
The topic has been locked.
More
7 years 2 weeks ago #152239 by Spix
Replied by Spix on topic HTML/ JavaScript program for input
Hey folks. I'm back with another tiny problem.
I improved my design a bit and have chosen two different musical scales (7 tones) with which my participants are going to work.
So I thought about packing both scales in the srcList and make two questions where one is using cases 1-7 and the other 8-14. The problem is that I cant tell the onkeydown section to activate for button one (keycode 49) the buttonpress event 1 and 8 at the same time.

The solution might be to copy the whole section, modify it for the other scale and tell each one which question is theirs. tpartner did this kind of assignment 5 posts above. So I did this and called all former "Zahlenanzeige" arrays "ZahlenanzeigeMixo" and "ZahlenanzeigeDorisch" but I messed it up.

I attached the question

File Attachment:

File Name: limesurvey..._MCT.lsq
File Size:5 KB
and template

File Attachment:

File Name: MCT_MODIFIED_TP.zip
File Size:33 KB
before I messed it up. Maybe some of you guys can help me out again. I hope its understandable what I have in mind.

Cheers
The topic has been locked.
More
7 years 2 weeks ago #152296 by Spix
Replied by Spix on topic HTML/ JavaScript program for input
I tried again and here are my questions and the template. The first one (mixo) works but the second (dorisch) does not want to.
The topic has been locked.
More
7 years 2 weeks ago #152298 by Spix
Replied by Spix on topic HTML/ JavaScript program for input
Ok for whatever reason it doesn't work in Chrome on my PC but with all other Browsers and Chrome on other devices it works just fine. So I think I can live with that.

Thanks folks
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose