Welcome to the LimeSurvey Community Forum

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

Need advice for two option boxes with one comment field and text before and behi

  • Berlin030
  • Berlin030's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 1 week ago #134239 by Berlin030
Hello,

I'm a beginner with a (layout/design?) problem which I can't solve. I spent hours to get a workaround with javascript, but no success. So hopefully some can help me.

I tried to descibe the problem in the attached graphic. the main problem is to get additional text behind the input field.

Thank you very much.
The topic has been locked.
  • elissa
  • elissa's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 1 week ago #134243 by elissa
I would simply use a list (radio) question type with other option. Add "Don't know" as the only answer category for the question. You may change the label for other option to "PSA-Wert (ng/ml)" and allow only numbers as other. You can set it in Advanced settings for the question.
Regards

Elzbieta Lesinska
LS voluntary Polish translator and supervisor
The topic has been locked.
  • Berlin030
  • Berlin030's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 1 week ago #134246 by Berlin030
Hello Elisa,

thank you for your explenation. So far I got it. The problem is, that "ng/ml" must be displayed behind the text field. I tried to replaced the generated code with javascript, but this didn't work. I think my script was overwritten by the generated form.
The topic has been locked.
More
8 years 1 week ago #134248 by jelo
In many (not all) item textfields you can set the text before and behind a field with a separator "|".

So try "PSA-Wert | (ng/ml)" in the item field. Perhaps it is working in the choosen question type.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • Berlin030
  • Berlin030's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 1 week ago #134250 by Berlin030
Thank you Jelo for the tip.
I tried it, but instead of separating the two words everything is written before the input field. I will try different writings and question types with this separator.
The topic has been locked.
More
8 years 1 week ago #134255 by jelo
That's a pity. This separator is still not working everywhere and it isn't documented well.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
8 years 1 week ago #134260 by tpartner
As far as I know, you cannot define an "Other" prefix and/or suffix in list radio or multiple choice questions.

Set up your survey to use JavaScript and add this script to the question source.

Code:
<script type="text/javascript" charset="utf-8">    
  $(document).ready(function() {  
 
    // Identify this question
    var thisQuestion = $('#question{QID}');
 
    // Define the suffix
    var newSuffix = 'ng/ml';
 
    // Insert "Other" suffix
    $('input.text', thisQuestion).after(newSuffix);
 
  });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • Berlin030
  • Berlin030's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
8 years 2 days ago #134645 by Berlin030
Hello tpartner,

thank you for this solution. I found a workaround which is not the best but did the job with javascript and replacement of the html code:

<script charset="utf-8" type="text/javascript">

$(document).ready(function() {
var oldHTMLa = document.getElementById('javatbd328441X94X1800PSA1').innerHTML;
var oldHTML = document.getElementById('javatbd328441X94X1800other').innerHTML;

var newHTML ="<input class='radio' type='radio' value='-oth-' name='328441X94X1800' id='SOTH328441X94X1800' onclick='checkconditions(this.value, this.name, this.type)'> <label for='SOTH328441X94X1800' class='answertext'>PSA-Wert</label> <label for='answer328441X94X1800othertext'> <input type='text' class='text empty' id='answer328441X94X1800othertext' name='328441X94X1800other' title='Sonstiges' value='' onkeyup='if($.trim($(this).val())!=''){ $('#SOTH328441X94X1800').click(); }; checkconditions(this.value, this.name, this.type);' enabled='enabled'></input> </label><span class='answertext'> (ng/ml)</span>";

document.getElementById('javatbd328441X94X1800other').innerHTML = oldHTMLa;
document.getElementById('javatbd328441X94X1800PSA1').innerHTML = newHTML;

$('#answer328441X94X1800othertext').click(function () {
$('#SOTH328441X94X1800').prop('checked', true);
});

$('#answer328441X94X1800othertext').on('keypress keyup blur',function (event) {
//this.value = this.value.replace(/[^0-9\.]/g,'');
$(this).val($(this).val().replace(/[^0-9,]/g,''));

});

});</script>
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose