dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: Disable drop down menu

  1. #1
    Join Date
    Oct 2004
    Posts
    1

    Disable drop down menu

    <script language="javascript">
    function disableIt(){
    document.form1.email.disabled = true;
    document.form1.password.disabled = true;
    document.form1.firstname.disabled = true;
    document.form1.lastname.disabled = true;
    document.form1.dob.disabled = true;
    document.form1.gender.disabled = true;
    document.form1.country.disabled = true;
    document.form1.update.disabled = true;
    }
    </script>
    <html>
    <form name=form1>
    .....
    ....
    <select name="country" id="country">
    <option value=malaysia selected>Malaysia</option>
    <option value=singapore>Singapore</option>
    </select>
    ...
    ...
    </form>
    </html>
    =================================

    I wanto use the javascript to disable the "drop down menu" which the name is "country". How to do it? Any thing wrong with my javascript code?

  2. #2
    Join Date
    Dec 2002
    Location
    Manchester, UK
    Posts
    6,276
    That code could be improved, but it should work (providing you call the disableIt() function at some point).

    It may actually be because your script is outside your HTML tags that's doing it.
    Every fight is a food fight when you’re a cannibal.

  3. #3
    Join Date
    Dec 2002
    Location
    Manchester, UK
    Posts
    6,276
    Here is an HTML template that I've just whipped up, if you use it when you are creating your pages it should eliminate a whole host of problems that could crop up further down the line.
    Attached Files Attached Files
    Every fight is a food fight when you’re a cannibal.

  4. #4
    Join Date
    Sep 2004
    Location
    Midwest
    Posts
    1,629
    <HTML>
    <Head>
    <Script Language=JavaScript>

    function disableForm(isForm){

    for (i=0; i<isForm.length; i++)
    {isForm[i].disabled = true};
    }

    </Script>
    </Head>
    <Body>
    <form name=Form1>
    .....
    ....
    <select name="country" id="country">
    <option value=malaysia selected>Malaysia</option>
    <option value=singapore>Singapore</option>
    </select>
    ...
    ...
    <input type=button value="Accept" onClick="disableForm(Form1)">
    </form>
    </Body>
    </HTML>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles