I have a Checkbox (PAT Test Required) which when unchecked I want to programmatically reset the following elements:-
Re-instate "Please Select" into the dropdown box (PAT Owner).
Clear Date (PAT Inspection Date).
Reset all three radio button to false (PAT Test Result).
Clear any text from the textfield (PAT Unique Identifier).
Here's the code I've used to clear the date field, textfield and dropdown but I just can't get the radio buttons (PAT_Test_Result) to reset to false. The bold and underlined line is the one I'm looking to correct:-
<script>
document.querySelector("input[name*='PAT_Test']").addEventListener("change", function test(){
//checks the checkbox if no
if(document.querySelector("input[name*='PAT_Test']").checked == false){
//wipe the PAT values
document.getElementById("InsertRecordPAT_Owner").value = "";
document.getElementById("InsertRecordPAT_Inspection_Date").value = ""; document.getElementById("InsertRecordPAT_Test_Result").value = false;
document.getElementById("InsertRecordPAT_ID").value = "";
}
});
</script>
I know this is a big "Ask" but it's simply outside of my JS skills. Any help would be genuinely appreciated.
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
Question
RonAnderson
I have a Checkbox (PAT Test Required) which when unchecked I want to programmatically reset the following elements:-
Here's the code I've used to clear the date field, textfield and dropdown but I just can't get the radio buttons (PAT_Test_Result) to reset to false. The bold and underlined line is the one I'm looking to correct:-
<script>
document.querySelector("input[name*='PAT_Test']").addEventListener("change", function test(){
//checks the checkbox if no
if(document.querySelector("input[name*='PAT_Test']").checked == false){
//wipe the PAT values
document.getElementById("InsertRecordPAT_Owner").value = "";
document.getElementById("InsertRecordPAT_Inspection_Date").value = "";
document.getElementById("InsertRecordPAT_Test_Result").value = false;
document.getElementById("InsertRecordPAT_ID").value = "";
}
});
</script>
I know this is a big "Ask" but it's simply outside of my JS skills. Any help would be genuinely appreciated.
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.