Hi,
Kindly help me in reading multiple text box values in array using Java Script. Thanks. My Code is shown below.
<script type="text/javascript">
function GetTBValues()
{
for(i = 0; i <document.forms[0].elements.length; i++)
{
elm = document.forms[0].elements[i]
if (elm.type=='text' && elm.name == 'DynamicTextBox')
{
alert(elm.value);
var readvalues[];
read
}
}
}
function GetDynamicTextBox(value){
return '<input name = "DynamicTextBox" type="text" value = "' + value + '" style="width: 305px valign=""" />' +
'<input type="image" id="ImageButton" src="Images/CancelImg_Small.jpg" onclick = "RemoveTextBox(this)" />'
}
function AddTextBox() {
var div = document.createElement('DIV');
div.innerHTML = GetDynamicTextBox("");
document.getElementById("TextBoxContainer").appendChild(div);
}
function RemoveTextBox(div) {
document.getElementById("TextBoxContainer").removeChild(div.parentNode);
}
function RecreateDynamicTextboxes() {
var values = eval('<%=Values%>');
if (values != null) {
var html = "";
for (var i = 0; i < values.length; i++) {
html += "<div>" + GetDynamicTextBox(values[i]) + "</div>";
}
document.getElementById("TextBoxContainer").innerHTML = html;
}
}
window.onload = RecreateDynamicTextboxes;
</script>
<table>
<tr>
<td>
<div id="Addresses">
<asp:panel ID="Panel1" runat="server">
<br />
<br />
<div id="TextBoxContainer">
<!--Textboxes will be added here -->
</div>
<br />
<input id="btnAdd" type="button" value="add" onclick="AddTextBox()"/><asp:Button ID="btnPost" runat="server" Text="GetRoutePlan" OnClientClick="GetTBValues()"/>
<asp:Panel ID="PnlDirections" runat="server" Visible="false">
<div id ="directionpanel" style="height: 390px;overflow: auto"></div>
</asp:Panel>
</asp:panel>
</div>
</td>
<td>
<div id ="map" style="height: 390px; width: 489px"></div>
</td>
</tr>
</table>