2/22/2025 8:00:15 AM
|
|
slxdeveloper.com Community Forums |
|
|
|
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
Forum to discuss using & developing the legacy SalesLogix Web Client (For versions 7.0 and earlier). View the code of conduct for posting guidelines.
|
|
|
| |
|
Re: Disabling a Datepicker with javascript code
Posted: 09 Jan 07 12:13 PM
|
fiogf49gjkf0d Ron,
It can be done; there are a few gotcha's.
Lets say you add a datepicker like this:
<#DATEPICKER name=jeffcontrol size=12>
The web DLL then creates two html controls that contain the date - one named "jeffcontrol", the other called "jeffcontrolcl". The former is the hidden control, the latter is the visible. The only JavaScript needed is to disable both of those, like this:
function jefftest() { // The first two lines are the easy part document.mainform.jeffcontrolcl.disabled = true; document.mainform.jeffcontrol.disabled = true;
// Here's the tricky part - hiding the image (if needed) var images = document.body.getElementsByTagName("IMG"); for (i = 0; i<= images.length-1; i++) { if (images[i].displaybox != undefined) { if (images[i].displaybox == "window.document.forms[0].jeffcontrolcl") { images[i].style.visibility = "hidden"; } } } } }
That disables the input text box. The gotcha, though, is that the image doesn't get disabled. It doesn't pop up the window, but it doesn't become disabled or hidden. If you want to disable or hide the image, there's a way around it, but it makes some assumptions and hard-codes a few things. If you look at the second part of the JS above, it gets a collection of all the images on the page. It looks through each image to see if it has a property called "displaybox" (the web DLL creates that property on the image tag for you). If it does, it then looks to see if the display box is the control associated with the one we want to hide the image for - in this case the control is called "jeffcontrolcl". If it matches, it hides the display box.
If you only have one date picker on your form, in theory, all you have to do is find the single image that has the displaybox property. When you find it, then disable it. If you have more than one control, you'll have to go the extra step (as above) to see if the associated control ("jeffcontrolcl") is the value for displaybox you want to disable. That means you'll have to hard code it, unless, of course, you can find a way to use the JS eval statement 0 but off the top of my head, I'm not sure what you'd use in the eval statement.
There may be an easier way, and the latter part of hiding the image may not be necessary, but the above does work.
Let me know if I just clouded the issue or if you have additional questions.
Jeff
|
|
|
|
Re: Disabling a Datepicker with javascript code
Posted: 09 Jan 07 12:21 PM
|
fiogf49gjkf0d Thanks for the quick response Jeff. That is a lot of work, what I did was to put the Datepickers, I have 3 on the page, inside of div tags, and I can hide/show the datepickers with divid.style.visibility = 'hidden', and divid.style.display = 'none', so I am doing this. |
|
|
|
Re: Disabling a Datepicker with javascript code
Posted: 09 Jan 07 2:16 PM
|
fiogf49gjkf0d Ron,
Great idea. I didn't think of using it with the datepicker tags, but I have used it for other things. As I said, I'm sure there was a more elegant way to do it. 
Jeff
|
|
|
|
You can
subscribe to receive a daily forum digest in your
user profile. View the site code
of conduct for posting guidelines.
Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
|
|
|
|
|
|
|
|