mike kong
mike kong

Reputation: 47

Input value didnt display

The code snippet below is form that embeded in the bootstrap modal to allow the user create a new subject for current system. In the form, I have included one text input to accept the data. In that text input, I have assign value = "incomplete" as the default value. However, the default value didnt show as expected when the webpage is running.

<div class="modal-body">
                        <form id="adminAddExamForm" method="POST"
                            th:action="@{/process_AdminAddExam}" th:object="${exam}">
                            <div class="mb-2">
                                <label for="status" class="col-form-label">Status</label>
                                <input type="text" value="incomplete" class="form-control" id="status" th:field="*{status}" autocomplete="off" disabled>
                            </div>
                       </form>
</div>

The below code snippet and screenshot is taken from chrome dev tools. Even though I have assign the value, but it still show nothing

<div class="mb-2">
                                <label for="status" class="col-form-label">Status</label>
                                <input type="text" value="" class="form-control" id="status" name="status">
                            </div>

Chrome Dev tools Screenshot

Upvotes: 0

Views: 2942

Answers (2)

mike kong
mike kong

Reputation: 47

Problem solved. I use the javascript to assign it the default value.

document.getElementById("status").defaultValue = "Incomplete";

Upvotes: 0

navylover
navylover

Reputation: 13539

No value = "incomplete" found in your codes. only value = ""

Replace

<input type="text" value="" class="form-control" id="status" name="status">

with

<input type="text" value="incomplete" class="form-control" id="status" name="status">

Update: If still doesn't show, check the css. Is there a property that makes the text transparent to its background.

Upvotes: 1

Related Questions