i want to enter text in textbox by dropdown only when clicking on button
i want that all this perform at client side by javascript..
this is dont in apsx page but i want it in .ascx
this is following code that i used in aspx page and successfully run as i want:
but i dont know how to make it work in .ascx
please solve it ..
i want that all this perform at client side by javascript..
this is dont in apsx page but i want it in .ascx
this is following code that i used in aspx page and successfully run as i want:
Code:
<script type="text/javascript">
function insertToken(element)
{
var ivxtoken = document.getElementById('DropDownList1').options[document.getElementById('DropDownList1').selectedIndex].value;
var element_v = document.getElementsByName(element)[0];
if (document.selection) {
element_v.focus();
sel = document.selection.createRange();
sel.text = ivxtoken;
return;
} if (element_v.selectionStart || element_v.selectionStart == "0") {
var t_start = element_v.selectionStart;
var t_end = element_v.selectionEnd;
var val_start = element_v.value.substring(0, t_start);
var val_end = element_v.value.substring(t_end, element_v.value.length);
element_v.value = val_start + ivxtoken + val_end;
} else {
element_v.value += ivxtoken;
}
}
</script>
<table style="width:100%;" width="%">
<tr>
<td class="style1" width="20%">
<asp:DropDownList ID="DropDownList1" runat="server" Width="150px">
<asp:ListItem>veera</asp:ListItem>
<asp:ListItem>jethva</asp:ListItem>
<asp:ListItem>pollux</asp:ListItem>
<asp:ListItem>ahmedabad</asp:ListItem>
<asp:ListItem>gujrat</asp:ListItem>
<asp:ListItem>India</asp:ListItem>
</asp:DropDownList>
</td>
<td class="style1" width="30%">
<input id="Button2" type="button" value="Inser Value" onclick="insertToken('TextBox1');" />
</td>
<td class="style1">
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td colspan="2">
<asp:TextBox ID="TextBox1" runat="server" Height="91px" TextMode="MultiLine"
Width="280px"></asp:TextBox>
</td>
<td>
</td>
</tr>
</table>
please solve it ..
Comment