Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Add % symbol after other specify text box

Hi,
I want to add % symbol after other specify text box. Can it be done?
Using the below code I hide text box until this option is checked. So, the adding % symbol should also be hidden until this option is checked. Please help me.
 
<style>
#[% QuestionName() %]_div input[type="text"],
#[% QuestionName() %]_div textarea {
    display: none;
}
</style>
 
<script>
$(document).ready(function(){
    toggleOtherSpecifies();
})
 
function SSI_CustomGraphicalRadiobox() {
    toggleOtherSpecifies();
}
 

function toggleOtherSpecifies() {
      var resp = SSI_GetValue('[% QuestionName() %]_2');
      $('#[% QuestionName() %]_2_other').toggle(resp == 2);
}

</script> 
asked Jun 20, 2019 by Abdul Bronze (2,525 points)

1 Answer

+2 votes
 
Best answer
Try this simple modification to that script:

<style>
#[% QuestionName() %]_div input[type="text"],
#[% QuestionName() %]_div textarea,
#[% QuestionName() %]_percentSymbol {
    display: none;
}
</style>

<script>
$(document).ready(function(){
    toggleOtherSpecifies();
    $('#[% QuestionName() %]_2_other').after('<span id="[% QuestionName() %]_percentSymbol">%</span>');
})

function SSI_CustomGraphicalRadiobox() {
    toggleOtherSpecifies();
}

function toggleOtherSpecifies() {
    var resp = SSI_GetValue('[% QuestionName() %]_2');
    $('#[% QuestionName() %]_2_other, #[% QuestionName() %]_percentSymbol').toggle(resp == 2);
}
 
</script>
answered Jun 20, 2019 by Zachary Platinum Sawtooth Software, Inc. (147,200 points)
selected Jun 21, 2019 by Abdul
Thank you so much Zachary, it works.
...