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
    New Coder
    Join Date
    Oct 2010
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to create The Function

    hello friends..
    I am working on the html code in which i using the List Control
    The Requirement that among the List element in which I choose the locations
    there is option in which whenever i select the option None From The List then it should Disply the empty textbox
    So how the function is declared
    Please tell me...

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts

  • #3
    New Coder
    Join Date
    Oct 2010
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Quote Originally Posted by devnull69 View Post
    Hello Friend...
    It is absolutely right.
    But whenever I am trying to create that code its not working My Code is
    not working....
    I have type the same code which you have given....

  • #4
    New Coder
    Join Date
    Oct 2010
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Quote Originally Posted by devnull69 View Post
    hello Friends...
    this is my code from the recent blog post.
    I want the following functionality...
    among the select option group control which consists of the name of the cities whenever I select the element from the lists then doesn't occur any event.
    but the list contains the element none from the list
    whenever I select the element none from the list then it displays the empty textbox but the following code is not working...please tell me


    <!DOCTYPE html>
    <html>
    <head>
    <script type="text/javascript">
    function showtextbox()
    {
    if(this.value==5)
    {document.getElementById('textbox').style.display='block';}
    else{document.getElementById('textbox').style.display='home';}
    }

    var loc=document.getElementByName('locations') [0];
    if(loc.addEventListener){loc.addEventListener('change',showtextbox,false);}
    else if(loc.attachEvent){loc.attachEvent('onchange',showtextbox);}
    </script>
    <meta charset=utf-8 />
    <title>JS Bin</title>
    <!--[if IE]>
    <![endif]-->
    <style>
    article, aside, figure, footer, header, hgroup,
    menu, nav, section { display: block; }
    </style>
    </head>
    <body>
    <select name="locations" size="5">
    <option value="1">Mumbai</option>
    <option value="2">Pune</option>
    <option value="3">Nashik</option>
    <option value="4">Aurangabad</option>
    <option value="5">None</option>
    </select>
    <input id="textbox" type="text"/ style="display: none;">
    </body>
    </html>

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,596
    Thanks
    80
    Thanked 4,631 Times in 4,594 Posts
    You have a couple of errors there. But why don't we just make it simpler?
    Code:
    <html>
    <head>
    <title>Demo</title>
    </head>
    <body>
    <form><!-- NEVER use form fields such as select and input without a form -->
    Location: 
    <select name="locations" 
        onchange="document.getElementById('other').style.display=this.value=='5'?'block':'none';">
        <option value="1">Mumbai</option>
        <option value="2">Pune</option>
        <option value="3">Nashik</option>
        <option value="4">Aurangabad</option>
        <option value="5">Other</option>
    </select>
    <div id="other" style="display: none;">
        Other: <input name="otherlocation" type="text">
    </div>
    </form>
    </body>
    </html>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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