I have a form that gets built in validation that once ran turns all inputs to readonly so that the user cannot modify them prior to submission.
The problem is that I have a dropdown on my page that cannot be modified after the page has been "validated". Disabling the dropdown is not an option because the value has to be able to be submitted. (I cannot use a hidden field to submit the selection due to external scripts that I cannot access.)
My Idea was to disable the dropdown onmouseenter and enable the dropdown on mouseleave. The onmouseenter code works fine, but no matter what I try I cannot seem to get the dropdown to re-enable.
Below I have an example of the basic pieces of code as a snippet.
I have also tried the following pairings to no avail;
.disabled=true; / .disabled=false;
.setAttribute('disabled','disabled'); / .removeAttribute('disabled');
.disabled=true; / .disabled="";
I would like to stick to specifically Javascript. What am I missing that keeps me from enabling this disabled dropdown at mouseleave?
Thanks
document.getElementById("lstLine").onmouseenter = function (){
var refVerifiedBox = document.getElementById('txtVerified');
if(refVerifiedBox.value !=""){
document.getElementById("lstLine").disabled = true;
}
}
document.getElementById("lstLine").onmouseleave = function (){
document.getElementById("lstLine").disabled = false;
}
<select id="lstLine">
<option value="testA">Test A</option>
<option value="testB">Test B</option>
</select>
<input id="txtVerified" value="Test" disabled=true;>