- Posts: 4
- Thank you received: 0
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
- Topic Author
- Offline
- New Member
Less
More
8 years 2 weeks ago #134239
by Berlin030
Need advice for two option boxes with one comment field and text before and behi was created 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.
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.
Attachments:
The topic has been locked.
- elissa
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 193
- Thank you received: 69
8 years 2 weeks ago #134243
by elissa
Elzbieta Lesinska
LS voluntary Polish translator and supervisor
Replied by elissa on topic Need advice for two option boxes with one comment field and text before and behi
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
Regards
Elzbieta Lesinska
LS voluntary Polish translator and supervisor
The topic has been locked.
- Berlin030
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
8 years 2 weeks ago #134246
by Berlin030
Replied by Berlin030 on topic Need advice for two option boxes with one comment field and text before and behi
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.
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.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5033
- Thank you received: 1257
8 years 2 weeks ago #134248
by jelo
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic Need advice for two option boxes with one comment field and text before and behi
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.
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
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
8 years 2 weeks ago #134250
by Berlin030
Replied by Berlin030 on topic Need advice for two option boxes with one comment field and text before and behi
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.
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.
- jelo
- Offline
- Platinum Member
Less
More
- Posts: 5033
- Thank you received: 1257
8 years 2 weeks ago #134255
by jelo
The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
Replied by jelo on topic Need advice for two option boxes with one comment field and text before and behi
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10109
- Thank you received: 3593
8 years 2 weeks ago #134260
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Need advice for two option boxes with one comment field and text before and behi
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.
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
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
8 years 1 week ago #134645
by Berlin030
Replied by Berlin030 on topic Need advice for two option boxes with one comment field and text before and behi
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>
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.