SIGEAL
Posts: 14
|
| Posted: 05/11/2004, 3:12 AM |
|
Hi,
I have a record form in which I need to disable some controls, depending on the logged user. I achieve this using the following javascript custom code (page_OnLoad) :
document.forms["AGENTS"].MATRICULE.disabled=true;
This works fine. However, when the user confirms his updates, the values in the disabled controls are lost (set to null or empty).
I must do something wrong. Can anybody help ?
Thanks
Christophe DAMOUR
sigeal@sigeal.fr
_________________
Christophe DAMOUR - SIGéal |
 |
 |
DonB
|
| Posted: 05/11/2004, 5:09 AM |
|
First, disabling them via the browser in javascript is not secure - the user
might disable javascript or have a "browser" tool where they could edit the
disabled fields.
Second, since you say "based on the logged user" I take this to mean the
disabling does not need to be done on the client side, but could be done
when the form is sent since you know at that time who is logged on.
You could put pairs of controls (textbox and label) for each field, then
show either the textbox or the label, based on their user id. This would be
easy to do by using this function:
Function hidecontrol(ctl)
ctl.Visible = (CCGetGroupID() <> 99) ' For example, hide control when
groupid is not 99
End Function
Then, in the before show event of each textbox/label, call that function:
Call hidecontrol(Eventcaller)
You might have a more complex function defined, depending on the rules that
apply to your situation.
Using this approach, you show labels instead of editable text boxes when
they are not authorized to change them. The labels do not become part of the
UPDATE statement so that won't put a NULL into the database.
--
DonB
http://www.gotodon.com/ccbth
"SIGEAL" <SIGEAL@forum.codecharge> wrote in message
news:640a0a721c695c@news.codecharge.com...
> Hi,
>
> I have a record form in which I need to disable some controls, depending
on the
> logged user. I achieve this using the following javascript custom code
> (page_OnLoad) :
>
> document.forms["AGENTS"].MATRICULE.disabled=true;
>
> This works fine. However, when the user confirms his updates, the values
in the
> disabled controls are lost (set to null or empty).
>
> I must do something wrong. Can anybody help ?
>
> Thanks
>
> Christophe DAMOUR
>sigeal@sigeal.fr
> _________________
> Christophe DAMOUR - SIGéal
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
SIGEAL
Posts: 14
|
| Posted: 05/11/2004, 9:41 AM |
|
DonB,
Thanks you for your quick answer. I thought your method would solve my problem, however I must still have missed something : the textbox I am trying to hide contains the primary key of my record. So what I want to do is the following :
- When the record is in insert mode, I want to let the user enter a value in the textbox
- When the record in not in insert mode (it is in edit mode), I just want to display the value (the user is not authorized to modify it)
When I apply your method, it works fine, except that when I want to confirm edits with the textbox not visible, I get a DB error because the primary key field is sent a NULL value.
Have you got a clue ?
_________________
Christophe DAMOUR - SIGéal |
 |
 |
Tony Do
|
| Posted: 05/12/2004, 5:24 PM |
|
I would make your primary control hidden. (call say customerID)
And then have another temp control (call tempID) that does not bound to any
database field
In the before insert event
EventCaller.customerID.value = EventCaller.tempID.value
In the before show event of your Record Form
Check to see if it is in edit mode or not, If it is in the edit mode then
hide your temp control
eg, in the before show event of your Record Form
If EventCaller.EditMode Then
EventCaller.TempId.visible = false
End If
"SIGEAL" <SIGEAL@forum.codecharge> wrote in message
news:640a1022b19a0a@news.codecharge.com...
> DonB,
>
> Thanks you for your quick answer. I thought your method would solve my
problem,
> however I must still have missed something : the textbox I am trying to
hide
> contains the primary key of my record. So what I want to do is the
following :
> - When the record is in insert mode, I want to let the user enter a value
in
> the textbox
> - When the record in not in insert mode (it is in edit mode), I just want
to
> display the value (the user is not authorized to modify it)
>
> When I apply your method, it works fine, except that when I want to
confirm
> edits with the textbox not visible, I get a DB error because the primary
key
> field is sent a NULL value.
>
> Have you got a clue ?
> _________________
> Christophe DAMOUR - SIGéal
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
SIGEAL
Posts: 14
|
| Posted: 05/12/2004, 11:25 PM |
|
Thank you Tony,
That sounds good. I'll try it and let you know.
_________________
Christophe DAMOUR - SIGéal |
 |
 |
|