Title name of the window should be the same as selected option

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rkyakkala
    New Member
    • Oct 2010
    • 11

    Title name of the window should be the same as selected option

    Hi,
    Please see the below html code.i am able to get whatever selected in the drop down list box.
    But i need to see the title name of the window [<title>]as it is selected could you please suggest in this regard.
    Follwing is my code:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>selected Item</title>
    <script language="javascript">
    function selecteditem(optionvalue){
    alert(optionvalue.options[optionvalue.selectedIndex].value);
    }
    </script>
    </head>
    <body>
    <form name="selform" onSubmit="selecteditem(devicelist)">
    <select name="devicelist">
    <option value="Device1">Device1</option>
    <option value="Device2">Device2</option>
    <option value="Device3">Device3</option>
    </select>
    
    <input type="submit" name="submit" value="click"/>
    </form>
    </body>
    </html>
    regards,
    rama krishna
  • JKing
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    Hi, here is a quick example that should help you.

    Code:
    <html>
    <head>
        <title>Watch Me Change</title>
    	<script type="text/javascript">
    		function setTitle()
    		{
    			var x = document.getElementById("devicelist");
    			document.title = x.options[x.selectedIndex].value;
    		}
    	</script>
    </head>
    <body>
    	<select name="devicelist" id="devicelist" onchange="setTitle();">
    		<option value="Device1">Device1</option>
    		<option value="Device2">Device2</option>
    		<option value="Device3">Device3</option>
    	</select>
    </body>
    </html>

    Comment

    • rkyakkala
      New Member
      • Oct 2010
      • 11

      #3
      Hi Jking,

      Thanks for your suggestion.
      Now i am able to see the selected item in my title.

      regards,
      Rama Krishna

      Comment

      Working...