I am attempting to insert data into an input that is labeled. "Proposed Destruction Date" Unfortunately the ids and name are dynamic and can't be used. I am attempting to find the label then the next input after the label. I am lost on the best way to do this.
Here is the code from the label and input. I don't have control over.
$("label:contains('Proposed Destruction Date:')").css("background-color", "green");
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="x-form-item " tabindex="-1" id="ext-gen234">
<label for="ext-comp-1071" style="width:154px;" class="x-form-item-label" id="ext-gen235">Proposed Destruction Date:</label>
<div class="x-form-element" id="x-form-el-ext-comp-1071" style="padding-left:159px">
<div class="x-form-field-wrap x-form-field-trigger-wrap" id="ext-gen236" style="width: 95px;">
<input type="text" size="10" autocomplete="off" id="ext-comp-1071" name="DEST1-2596" class="x-form-text x-form-field" style="width: 70px;">
<img src="/LMS/js1910280933/ext/resources/images/default/s.gif" alt="" class="x-form-trigger x-form-date-trigger" id="ext-gen237">
</div>
<div class="lms-form-field-msg-area" style="left:262px;" id="ext-gen238">
<span id="ext-comp-1071-msg" class="lms-form-field-error"></span>
</div>
</div>
<div class="x-form-clear-left">
</div>
</div>
Here is the code I have written to try and find this input. So far I can't find the label or if I can it is not turning green. Please let me know if there is a better way to find this input with out the id or name since those change.
Thanks for all your help
doc.readyis required.$("label:contains('Proposed Destruction Date:') + .x-form-element input").val(dts1);I have a followup question this is a date field in the first input box it is in "MM/DD/YYY" when I move it from the variable to the second input it is"YYYY/MM/DD" How can I control it in the variable. I can create a new question if needed. I would like it to show "MM/DD/YYYY" in the second box if you type it manually that is how it is.