You are viewing limited content. For full access, please sign in.

Question

Question

Dynamically changing Text Above Field and Text Below Field values with javascript

asked on April 22, 2017

Hi,

 

I have a field that is to contain a numeric field from a Lookup Rule (SQL table)

I also have a field "ValueDataType"that is populated that states type of numeric value (ie % or £ etc)

What I would like to do is change the "Text Before/After Field" entries to a "£/%/$/p.a." depending on value of "ValueDataType" field .... is this possible with javascript?

 

Below is the Field16 inspect code and it is this line I am trying to trap: <label class="cf-helptext un-help" for="Field16">%</label></div></li>

 

<li attr="Metric_Value" attrtype="text" name="q16" id="q16" class="ActualValue form-q label-left"><label class="cf-label" for="Field16">Metric Value</label><div class="cf-field ws-success"><input type="text" id="Field16" name="Field16" aria-label="Field16" class="singleline cf-small user-success" maxlength="4000" list="datalistField16" data-list-focus="true" vo="e" lookupalt="true" readonly="readonly">

<datalist id="datalistField16"></datalist>

<label class="cf-helptext un-help" for="Field16">%</label></div></li>

 

Many thanks

0 0

Replies

replied on April 23, 2017

If I'm understanding you correctly, your ValueDataType field is populated from a database. You want to take that value and put it into the helptext above/under another field, right?

Let's say the field ID of your "ValueDataType" field is Field15. You can try this:

$(document).ready(function() {
    var $helptext = $('#q16 > label.cf-helptext');
    $('#Field15').on('change', function() {
        $helptext.html($(this).val());
    });
});

 

0 0
replied on April 25, 2017

Thank you that ... not had much luck though. Will keep trying

0 0
replied on April 25, 2017

I got this to work ... does not look elegant but does the job!

thanks for your help as it let me find the element I was looking for

ActualValue.nextElementSibling.nextElementSibling.innerHTML = ' %'

(ActualValue is the classname for the field I am trying to populate)

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.