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 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2002
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Internet Explorer Usins SELECT tag with javascript

    Hi

    I m new to HTML and Javascript.
    What I want to do is when the user select some text
    from the Drop Down List, it should get displayed in
    the web Page.

    suppose the SELECT tag contains:-
    India
    USA
    UK

    and if the user selects USA. then it should get
    displayed in the Webpage in Bold with font color as
    Red

    Please tell me how to do this
    Have a nice day

    Anand

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Mumbai, India
    Posts
    218
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Here's the code :
    (Wont work with NS 4.X)

    Code:
    <html>
    <head>
    <title>Select</title>
    <script language="JavaScript">
    function displayOption(divName)
    {
     document.getElementById(divName).innerText=document.form1.select1.options[document.form1.select1.selectedIndex].value;
    }
    </script>
    </head>
    <body bgcolor="#FFFFFF">
    
    <!--BEGIN FORM-->
    <form name="form1">
       <select name="select1" onChange="displayOption('div1');">
          <option value="India">India</option>
          <option value="USA">USA</option>
          <option value="UK">UK</option>
       </select>
    </form>
    <!--END FORM-->
    
    <div id="div1" style="font-family:verdana,arial,helvetica; font-weight:bold; color:#FF0000"></div>
    
    </body>
    </html>


  •  

    Posting Permissions

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