My Form is something like this. I have saved field_name and field_values into a MySQL table.
The table in my database is like this
ID | field_name | field_value
12 | field1 | Sample text
13 | field2 | Plagiarised
How Can I load these values into the form below"
By that I mean how can I change value of field1 to "Sample Text" according to the table and the rest of the fields using jQuery Ajax on page load?
This form is generated dynamically as its built through a form-builder.
<form id="form-preview" class="TTWForm" method="post" novalidate="">
<div id="field1-container" class="field f_100">
<label for="field1">
Comments
</label>
<textarea rows="5" cols="20" name="field1" id="field1" required="required"></textarea>
</div>
<div id="field2-container" class="field f_100 radio-group required">
<label for="field2-1">
Level of work
</label>
<div class="option clearfix">
<input name="field2" id="field2-1" value="Need Revisions" type="radio">
<span class="option-title">
Need Revisions
</span>
</div>
<div class="option clearfix">
<input name="field2" id="field2-2" value="Plagiarised" type="radio">
<span class="option-title">
Plagiarised
</span>
</div>
<div class="option clearfix">
<input name="field2" id="field2-3" value="Archive it" type="radio">
<span class="option-title">
Archive it
</span>
</div>
</div>
<div id="form-submit" class="field f_100 clearfix submit">
<input value="Submit" type="submit">
</div>
</form>
You can use the returned data from ajax using json encode
take a look here:
Dynamically fill in form values with jQuery