GeeCON Prague 2014*
The moose likes HTML, CSS and JavaScript and the fly likes how to make select list uneditable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to make select list uneditable" Watch "how to make select list uneditable" New topic
Author

how to make select list uneditable

srinivas sv
Greenhorn

Joined: Oct 04, 2003
Posts: 13
helo java ranchies,
if some action happens i don't want the user to change the element from the list box, at the same time i want this value to be passed with the form, for this reason i can't disable the list. Is there any function in javascript which makes the list uneditable.
thanx in advance
jyothsna kumari
Ranch Hand

Joined: Jul 21, 2003
Posts: 108
hi,
As far as i know one cannot edit the data in the list box or combo box.So there is no question in editing the data.
If you are using textbox or textarea then you can do that by specifying the input field as readonly.Something like this,
<input readonly value="text">
In this way you can make the field uneditable.

Jyothsna
srinivas sv
Greenhorn

Joined: Oct 04, 2003
Posts: 13
thanks jyothsna for ur reply,
editable in the sense, the user selecting some other value from the list box
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You can do couple things you can do,
One, you can use hidden elements and pass the information to them. Then you can disable the dropdown and be able to pass the information from them.
Second, you can have a function that will always set the item to the selected item that you want when the list is changed.
Third, you can remove all of the other items from the dropdown so there are no other choices to pick from.
Eric
srinivas sv
Greenhorn

Joined: Oct 04, 2003
Posts: 13
thank u very much eric,
is there any single function in javascript using which i can do this task
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
what one would you want to see 1,2,or 3?
srinivas sv
Greenhorn

Joined: Oct 04, 2003
Posts: 13
once again thank u eric
i know the three ways of implementation, but is there any short cut,
example if i want to disable a form i use only a single function like formName.controlName.disable in the same way is there any single function which makes the select list read only.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
try doing something like this
<form name="Blah" onsubmit="document.Blah.Test.disabled = false;">
<select name="Test" disabled>
srinivas sv
Greenhorn

Joined: Oct 04, 2003
Posts: 13
thank u very very much eric
it is working!
 
GeeCON Prague 2014
 
subject: how to make select list uneditable