0

I'm trying to display the data stored in a variable into a form field. The variable programme_title definitely holds the data as I have tested it through other methods. However, when I use the following, the entry form field simply reads "programme_title". How can I get the data from the variable to fill the field?

<div> Item 1 <input name=item_description-0-item value=programme_title> 
</div>
nmh
  • 491
  • 2
  • 8
  • 23
  • Possible duplicate of [Set the value of an input field](https://stackoverflow.com/questions/7609130/set-the-value-of-an-input-field) – Phani Kumar M Sep 08 '17 at 11:07

1 Answers1

0

I assume from the "jinja2" tag you're using jinja2 templates, where variables/expressions are placed in {{ }}:

<input name="item_description-0-item" value="{{ programme_title }}">

If it's just HTML + JavaScript then set the value property of the input element, for example by this JavaScript expression:

document.querySelector('[name="item_description-0-item"]').value = 'programme_title';
Tomas Varga
  • 1,432
  • 15
  • 23