开发者

input fields not showing default value

开发者 https://www.devze.com 2023-03-17 21:02 出处:网络
I have a form with some input fields. I have value=\"something here\" set on most of them. However, when i load the page in firefox the input fields are not filled in.

I have a form with some input fields. I have value="something here" set on most of them. However, when i load the page in firefox the input fields are not filled in.

Firebug shows a value attribute with the correct value in it. But its not showing on the screen. When I submit the form, it doesnt pass the values either.

Here's the output from my PHP Script which just dumps the array.

}
[servDate] => 07-07-2011
[time1] => 8:00
[odo1] => 12345
[report1] => 
[time2] => 8:30
[odo2] => 12350
[report2] => 
[time4] => 9:00
[odo4] => 12359
[report4] => SUBJECT DEPARTS HOME
[time5] => 9:30
[odo5] => 12369
[report5] => SUBJECT ARRIVES AT WORK
[time98] => 9:35
[odo98] => 12369
[report98] => 
[time99] => 10:00
[odo99] => 12399
[report99] => 
[servHrs] => 
[id] => 
)

The form is as follows:

<form id="reportForm">
    Service Date: <input type="text" name="servDate" id="servDate" size="10" value="<? echo date("m-d-Y"); ?>" /><button id="servDateBtn"><img src="../includes/calendar.png" /></button><br />
    <table id="reportTable" name="reportTable">
        <tr>
            <th>&nbsp;</th>
            <th>Time</th>
            <th>Odometer</th>
            <th>Actions</th>
        </tr>
        <tr>
            <TD width="20px">&nbsp;</TD>
            <TD><INPUT type="text" name="time1" id="time1" size="4" /> 
            <script type="text/javascript">
                $(document).ready(function() {
                    $('#time1').timepicker({
                        showPeriod: false,
                        showLeadingZero: false
                    });
                });
            </script>
            </TD>
            <td><input type="text" name="odo1" id="odo1" class="odo" size="6" /></td>
            <td><input type="text" name="report1" id="report1" size="42" value="Dispatched Investigator." readonly="readonly" /></td>
        </TR>
        <tr>
            <TD width="20px">&nbsp;</TD>
            <TD><INPUT type="text" name="time2" id="time2" size="4" /> 
            <script type="text/javascript">
                $(document).ready(function() {
                    $('#time2').timepicker({
                        showPeriod: false,开发者_如何学Python
                        showLeadingZero: false
                    });
                });
            </script>
            </TD>
            <td><input type="text" name="odo2" id="odo2" class="odo" size="6" /></td>
            <td><input type="text" name="report2" id="report2" size="42" value="Investigator arrived at first field location." readonly="readonly" /></td>
        </TR>
    </table>
    <table>
        <tr>
            <TD width="20px">&nbsp;</TD>
            <TD><INPUT type="text" name="time98" id="time98" size="4" /> 
            <script type="text/javascript">
                $(document).ready(function() {
                    $('#time98').timepicker({
                        showPeriod: false,
                        showLeadingZero: false
                    });
                });
            </script>
            </TD>
            <td><input type="text" name="odo98" id="odo98" class="odo" size="6" /></td>
            <td><input type="text" name="report98" id="report98" size="42" value="Investigator departed last field location." readonly="readonly" /></td>
        </TR>
        <tr>
            <TD width="20px">&nbsp;</TD>
            <TD><INPUT type="text" name="time99" id="time99" size="4" /> 
            <script type="text/javascript">
                $(document).ready(function() {
                    $('#time99').timepicker({
                        showPeriod: false,
                        showLeadingZero: false
                    });
                });
            </script>
            </TD>
            <td><input type="text" name="odo99" id="odo99" class="odo" size="6" /></td>
            <td><input type="text" name="report99" id="report99" size="42" value="Investigator suspended." readonly="readonly" /></td>
        </TR>
    </table>
    <br /><button id="addEntry">Add Entry</button>&nbsp;<button id="delEntry">Delete Entry</button>
    <br />
    Service Hours: <input type="text" name="servHrs" id="servHrs" size="4" />
    <input type="hidden" name="id" class="client" value="<? echo $id ?>" />
</form>

which opens in a jquery dialog.

The other forms on my page open in a dialog box and work fine. I've verified I'm not using ANY duplicate IDs or NAME tags. Whats weirder is sometimes it will work and sometimes it wont.

For security reasons, I'm not allowed to show u the actual page as this system contains confidential client information.


Does it only happen when the page is reloaded? If so, it's likely because Firefox is remembering the old values. Does it happen if you open the page in a new tab?


So I know its been ages since this question was asked. But because there is no valid answer here and to help people in the future:

Browser does store defaultValue as been already mentioned. But using a meta tag that directs browser to not cache at all is a very bad solution.

Cause:

The problem this matter even becomes an issue was (in my case) application was assigning an empty defaultValue and when the data from the server was coming in it wasn't updating it.

Solution:

Avoid re-assignment of defaultValue from Empty to Actual Value. Just render the input field when the Actual Value is available.

0

精彩评论

暂无评论...
验证码 换一张
取 消