skip to Main Content

Is there a way to assign variable to an Element Name so that I can access the element and change the values:


[% FOREACH field IN ['id','type','updatedt','lastcheckdt'] %]
    <div class="row col-md-3 col-sm-6">
        <dl class="details-dl">
            <label>[% field %]</label>
            <div class="details-dg">
                <dd name=[% field %] class="float-right">[% order.$field %]</dd>    
            </div>
        </dl>
    </div>
[% END %] 

I can format the datetime for updatedt:

let dt_formatted = convertDateFormat("[% order.updatedt %]");
$( "[name='updatedt']" ).val(dt_formatted);

Unfortunate assigning [ % field %] to name does not assign any value to name:

<dd name=[% field %] class="float-right">[% order.$field %]</dd>    

2

Answers


  1. Chosen as BEST ANSWER

    use .html() instead of .val to access the property in <dd>

    $( "[name='updatedt']" ).val(dt_formatted); --> wrong
    $( "[name='updatedt']" ).htmtl (dt_formatted); --> correct
    

  2. Looks like your are missing the quotes here:

    <dd name="[% field %]" ...>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search