[Javascript] How to prevent user from selecting in select box

Antony Paul antonypaul24 at hotmail.com
Thu Apr 1 22:13:06 CST 2004


I acknowledge that you suggested reverting the changes in the onchange()
event.
The problem with hidden field is when checking the value.length it will give
error when there is another disabled field with same name .  It was possible
to avoid this error by assigning a different name to the hidden field. But
for that I have to change the JSP coding.

Thanks for the suggestions
Antony Paul

----- Original Message -----
From: "Chris T" <christ at saeweb.com>
To: "[JavaScript List]" <javascript at LaTech.edu>
Sent: Thursday, April 01, 2004 7:38 PM
Subject: Re: [Javascript] How to prevent user from selecting in select box


> > Using hidden field also is not viable because of javascript validation.
It
> > will throw error when checking the obj.value.length.
>
> I'm a little confused on this statement.  Why will it throw an error when
> checking the length of a value?
>
> > At last I found a solution. Keep the select box enabled. When loading
the
> > page create a two dimensional array which contains name and values of
> select
> > boxes to be disabled. In the onchange() event of select box call a
> function
> > which checks this name in the array and if found it restore its value
with
> > one found in the array. It works for me.
>
> I think if you look back, you'll see that I suggested something similar
> since all js-enabled browsers wound (should) be able to handle. I even
> suggested that you alert the user of why it reverted to the original
value.
>
> Now if you wanted to take this one step further - at the risk of having
the
> code rendered useless in some browsers - you can add custom attributes to
> that element and read those in the onChange event. Something like
> isDisabled="true" originalValue="4" or something along those lines.
>
> Chris Tifer
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>



More information about the Javascript mailing list