yadagiri uppari

yadagiri uppari

  • NA
  • 277
  • 190k

apply items(bold,italic) when item selected from drpdownlst

Jul 18 2013 4:29 AM
hi...after typing text in textbox then iem selected from dropdownlist..then it has to b applied
aspx:
function ChangeFont() {
            var selectTags = document.getElementById("DropDownList1");
            var fontValue = "";

            for (i = 0; i < selectTags.length; i++) {
                // Returns the index of the selected option
                whichSelected = selectTags[i].selectedIndex;

                // Returns the selected options values
                fontValue += selectTags[i].options[whichSelected].text + " ";
            }

            var anchor = document.getElementById("TextBox1");
            anchor.style.font = fontValue;
        }
    </script>
</head>
<body>
<form id="frm" runat="server">
<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine"></asp:TextBox>
    <br />
    font-style:
    <asp:DropDownList ID="DropDownList1"  runat="server" 
    AutoPostBack="true" OnSelectedIndexChanged="ChangeFont();">
     <asp:ListItem>Italic</asp:ListItem>
    <asp:ListItem>normal</asp:ListItem>
    <asp:ListItem>oblique</asp:ListItem>
  </asp:DropDownList>
 </form>
</body>
</html>

Answers (9)