I'm creating form fillable pdfs that have a lot of drop down lists with the same options: X = OK, D = Defect, N = Not Applicable, and O = Repair Made. A lot of the time everything will be marked OK, so rather than selecting X in each drop down list, it would be great if clicking a button at the top would set the value for each drop down to X.
It would be great if it only marked empty drop downs as OK so if the user already filled out with something other than OK it doesn't overwrite it.
As far as I understand, you have a bunch of drop down lists with options X, D, N and O. You want a button which will set all unset drop downs to X when clicked.
Below is a "poorly written" code sample for that. You can use it as a starting point.
document.getElementById("okSetBtn").addEventListener("click", function(e) {
document.querySelectorAll(".status").forEach(a => a.value = a.value || "X");
});
<button id="okSetBtn">Set unset to OK</button>
<div>
<label>Status 1</label>
<select class="status" id="status1">
<option value=""></option>
<option value="X">OK</option>
<option value="D">Defect</option>
<option value="N">Not Applicable</option>
<option value="O">Repair Made</option>
</select>
</div>
<div>
<label>Status 2</label>
<select class="status" id="status2">
<option value=""></option>
<option value="X">OK</option>
<option value="D">Defect</option>
<option value="N">Not Applicable</option>
<option value="O">Repair Made</option>
</select>
</div>
<div>
<label>Status 3</label>
<select class="status" id="status3">
<option value=""></option>
<option value="X">OK</option>
<option value="D">Defect</option>
<option value="N">Not Applicable</option>
<option value="O">Repair Made</option>
</select>
</div>