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

More
3 years 4 months 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.
Attachments:

Please Log in or Create an account to join the conversation.

LimeSurvey Partners
More
3 years 4 months 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

Please Log in or Create an account to join the conversation.

More
3 years 4 months 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.

Please Log in or Create an account to join the conversation.

More
3 years 4 months 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

Please Log in or Create an account to join the conversation.

More
3 years 4 months 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.

Please Log in or Create an account to join the conversation.

More
3 years 4 months 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

Please Log in or Create an account to join the conversation.

More
3 years 4 months 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.

<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.
Official LimeSurvey Partner - partnersurveys.com

Please Log in or Create an account to join the conversation.

More
3 years 4 months 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>

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!