Welcome to the LimeSurvey Community Forum

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

Multiple numerical input and default value change with onclick?

  • kraycarey
  • kraycarey's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 5 months ago #143192 by kraycarey
I am looking for a little help. I am using the latest version of LimeSurvey - version 2.5+. I have a "Multiple numerical input" question for which I have assigned a default value of 0. To make the end user experience better, I'd like to also include within the below <input *> the parameter of onclick="this.value='' " ... this will remove the need to delete the zero prior to entering a value within the field.

<input class="text form-control numeric em_sq_validation good" name="899495X11X223SQ005" id="answer899495X11X223SQ005" value="0" onkeyup="fixnum_checkconditions(this.value, this.name, this.type, 'onchange',1)" title="Only numbers may be entered in this field." maxlength="25" type="text">

Thanks in advance!

kcarey
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 5 months ago #143209 by tpartner
Set up your survey to use JavaScript and place the following script in the source of the question:

Code:
<script type="text/javascript" charset="utf-8">    
 
  $(document).ready(function() {    
    $('#question{QID} input.text').focus(function() {
      if ($(this).val() == 0) {
        $(this).val('');
      }
    }).blur(function() {
      if ($(this).val() == '') {
        $(this).val(0);
      }
    });
  });
</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.
  • kraycarey
  • kraycarey's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 5 months ago #143254 by kraycarey
Thanks for your help!
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose