SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2010
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I want to disable the text box, based on the value selected from the list box

    hi

    all

    I want to disable the text field base on the value selected from the list box.


    Please help me out



    Thanks & Regards
    MD.Samiuddin

  2. #2
    Non-Member
    Join Date
    Dec 2010
    Location
    /home/pc
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If the value of the selected item in the list box == a certain value, set the disabled property of the textbox to true.

  3. #3
    SitePoint Zealot
    Join Date
    Dec 2010
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for ur reply


    please give the code for this


    thanks & regards

  4. #4
    SitePoint Zealot
    Join Date
    Dec 2010
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I want to disable the text box, based on the value selected from the list box

    Hi

    all

    I want to disable the text box based on the value selected from the list box

    please help me out



    Thanks & Regards.

    MD.Samiuddin

  5. #5
    Non-Member
    Join Date
    Dec 2010
    Location
    /home/pc
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you at least provide the code for the select list and the textbox? and then we can help you with the javascript.

  6. #6
    Non-Member
    Join Date
    Dec 2010
    Location
    /home/pc
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why are you duplicating your question in another thread?

    This thread is the same as this one

  7. #7
    SitePoint Zealot
    Join Date
    Dec 2010
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi
    this is my code

    <select name="vcat" id="vcat" >Vehicle-Type
    <option name="vcat" value="own">Own
    <option name="vcat" value="attached">Attached
    </option>
    </select>
    <input type="text" name="vcomm">
    <input type="text" name="vstatus">

    when i selected the 'own' from the list box then i want to disable the two text boxes

    thanks & regards

    MD.Samiuddin

  8. #8
    Non-Member
    Join Date
    Dec 2010
    Location
    /home/pc
    Posts
    186
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That html has errors in it.

    Why have you given names to the options? How will you be using those names?

    Also, not all your option labels are enclosed properly within option tags.

    You need to fix those errors first.

  9. #9
    SitePoint Addict bronze trophy AllanP's Avatar
    Join Date
    Sep 2010
    Location
    Australia
    Posts
    298
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    This will do it for you.

    You need to have the first select box ( "select ...") so that the onchange handler fires when you move from it to the other two boxes.

    Code :
    <!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
     
    <head>
     
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Disable Text Boxes</title>
    <script type="text/javascript">
    <!--
     function disableTextBox(obj)
      { var selected=document.myForm.mySelect.options[obj.selectedIndex].value;
       // invalid selection 
        if(selected=="999"){ return; }
         // ------------
       // valid selection
        if(selected=="own")
         { document.myForm.vcomm.disabled=true; 
           document.myForm.vstatus.disabled=true;  
         }
      }
    //-->
    </script>
    </head>
     
    <body>
     
    <form name="myForm">
      <p><select name="mySelect" onchange="disableTextBox(this)">
      <option value="999">Select ...</option>
      <option value="own">Own</option>
      <option value="attached">Attached</option>
      </select> <input type="text" name="vcomm" value="12345">
      <input type="text" name="vstatus" value="98765"> </p>
    </form>
     
    </body>
     
    </html>

  10. #10
    SitePoint Addict bronze trophy AllanP's Avatar
    Join Date
    Sep 2010
    Location
    Australia
    Posts
    298
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Answered in the php forum


Bookmarks

Posting Permissions

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