Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need Help Toggling the Disabled Property 1

Status
Not open for further replies.

LyndonOHRC

Programmer
Sep 8, 2005
603
US
I've tried onfocus/onblur and the mocvueover seen below; I've also tried using getelementbyid to set disabled back to false, but nothing seems to remove the disabled property. It seems to me like the onfocus and the onmouseout never fires once the input is disabled.

Can this be accomplished?

Any help appreciated.
Lyndon

Code:
Year: <input size="5" type="text" name="OrderYear" id="OrderYear" onmouseover="this.disabled=true;" value="2018" onmouseout="this.disabled=false;"> 
Track: <input size="10" type="text" name="OrderTrack" id="OrderTrack" onmouseover="this.disabled=true;" value="RP" onmouseout="this.disabled=false;"> 
Order Number: <input size="10" type="text" name="OrderNumber" id="OrderNumber" onmouseover="this.disabled=true;" value="001" onmouseout="this.disabled=false;">

Lyndon
 
Correct, once the input is disabled it no longer responds to any events because its disabled.

You would need an external event to re-enable it for example a click on a different item, such a button or link.,

Why are you disabling them when you mouseover them? And then want to re-enable them once the mouse is out? What are you trying to accomplish? Seems a bit pointless.





----------------------------------
Phil AKA Vacunita
----------------------------------
OS-ception: Running Linux on a Virtual Machine in Windows which itself is running in a Virtual Machine on Mac OSx.

Web & Tech
 
Sorry, I got deep in the weeds on a bad idea...

After a good night sleep; I changed these input elems to hidden, and am now displaying their values in span's. These input values are set by other form actions. I don't want the user to edit them directly; back on track now thanks. LOL

Bright side, learned something about how an input behaves that I hadn't known.

Thanks Lyndon

Lyndon
 
That would be what the "readonly" attribute of input elements is for. You can set them to readonly so they cannot be altered, but are still submitted with the form if that's the objective.

Code:
<input type="text" readonly=true>

Readonly makes it so they cannot be edited, but still respond to events and other actions on it. You can use JS to set it as well is you want to, but there's no real point. Just set it directly at the HTML level.



----------------------------------
Phil AKA Vacunita
----------------------------------
OS-ception: Running Linux on a Virtual Machine in Windows which itself is running in a Virtual Machine on Mac OSx.

Web & Tech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top