hi,
i want to call a javascript function on selected index changed of dropdownlist in ajax page.
<script type="text/javascript">
function moveRight(){
document.getElementById('TextBox1').style.position= 'absolute';
document.getElementById('DropDownList1').style.position= 'absolute';
var obj=document.getElementById('TextBox1');
var x=document.getElementById('DropDownList1').offsetLeft;
var y=document.getElementById('DropDownList1').offsetTop;
alert(x);
obj.style.left=x;
obj.style.top=y + 'px';
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ab" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="up" runat="server">
<ContentTemplate>
<div>
<asp:DropDownList ID="DropDownList1" runat="server"
onselectedindexchanged="DropDownList1_SelectedIndexChanged"
AutoPostBack="True" Width="185px" Height="18px" AppendDataBoundItems="True" >
<asp:ListItem>Nokia</asp:ListItem>
<asp:ListItem>LG</asp:ListItem>
<asp:ListItem>Samsung</asp:ListItem>
<asp:ListItem>Motorola</asp:ListItem>
</asp:DropDownList>
</div></ContentTemplate></asp:UpdatePanel>
<p>
<asp:TextBox ID="TextBox1" runat="server" Width="164px" Height="16px"
Visible="false" style="top: 98px; left: 130px; position: absolute;"></asp:TextBox>
</p>
<p>
</p>
</form>
</body>
protected void Page_Load(object sender, EventArgs e)
{
DropDownList1.Items.Add("Other");
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedItem.Value == "Other")
{
TextBox1.Visible = true;
string scr = "<script type='text/javascript'>";
scr += "alert('hi');";
scr += "moveRight();";
ScriptManager.RegisterClientScriptBlock(DropDownList1, typeof(DropDownList), "moveRight", scr, true);
}
else
TextBox1.Visible = false;
}