Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post

    readonly menu list...

    Hey,

    I know that I can use HTML to "disable" a drop down list - but I dont want to use this method... I need to set some javascript which will not allow the user to select the drop down.... basically disabling it, but still having it there.

    I've tried:

    Code:
    function readonlyDrop(ctrl)
    {
    	this.selectedIndex = 0;
    	readOnlyAlert();
    }
    and on the drop down

    <select onclick="readonlyDrop(this)">

    I've tried <select readonly> but select's dont seem to support this...

    any ideas how I can do it?

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    onFocus=this.blur()

    ?

    Otherwise, I'd look again at exactly what you're trying to achieve. Will re-presenting the data, say in a <ul>, do the same thing? Do you really need it in a select box?

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post
    the disabled or not select menu is based on the users access rights.

    the page can be read/write where the user can update values - and read only where they can see elements but not update them. This is what I want to acheive with the select box.

    I might have to just disable it.... but the other text input fields are readonly and stay the same colour... I wonder if I can disable it but apply a style to make it not greyed out?

  • #4
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Spudhead
    onFocus=this.blur()
    that has actually done the trick!!

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    You should still double-check the access rights in the server-side as anyone can bypass it by typing this in the address bar.

    javascript:document.forms[0].theSelect.onfocus=null;void(0);


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •