Note that there are some explanatory texts on larger screens.

plurals
  1. POSetting Values of textboxes that were created using Javascript
    primarykey
    data
    text
    <p>I had a form in which I made some textboxes using javascript. Basically I gave a button and Onclick of that button I add a Textbox using Javascript. These values were then taken in a string on the server side and stored in different List columns.</p> <p>Now I want to create Edit Functionality. So I have to retrieve values from the List COlumns and Insert it in the Textboxes. This was easy when my controls were server controls but How can I do this for textboxes that were created using Javascript.</p> <p>I am new to client side scripting. Any help will be appreciated.</p> <p>All I need is a way to get the values from the List COlumn and then create those textboxes again with those values.</p> <p>PS: Please advise if you wana see the code for how I have created the textboxes and got those values on the server side. Thanks!</p> <p>Javascript Code to create Textboxes:</p> <pre><code>&lt;script type="text/javascript"&gt; function GetDynamicTextBoxB(value) { return '&lt;input name = "DynamicTextBoxB" type="text" value = "' + value + '" /&gt;' + '&lt;input type="button" value="Remove" onclick = "RemoveTextBoxB(this)" /&gt;' } var y = 0; function AddTextBoxB() { if (y &lt; 10) { var div = document.createElement('DIV'); div.innerHTML = GetDynamicTextBoxB(""); document.getElementById("TextBoxContainerB").appendChild(div); } else { alert("Only 10 CSPs can be added") } y++ } function RemoveTextBoxB(div) { document.getElementById("TextBoxContainerB").removeChild(div.parentNode); } function RecreateDynamicTextboxesB() { var values = eval('&lt;%#Values%&gt;'); if (values != null) { var html = ""; for (var i = 0; i &lt; values.length; i++) { html += "&lt;div&gt;" + GetDynamicTextBoxB(values[i]) + "&lt;/div&gt;"; } document.getElementById("TextBoxContainerB").innerHTML = html; } } $("#tabs-1").ready(RecreateDynamicTextboxesB); // // window.onload = RecreateDynamicTextboxesB; &lt;/script&gt; </code></pre> <p>Code Behind to Get these values on the server side and storing in List COlumns</p> <pre><code>string PartyACSP1 = string.Empty, PartyACSP2 = string.Empty, PartyACSP3 = string.Empty, PartyACSP4 = string.Empty, PartyACSP5 = string.Empty, PartyACSP6 = string.Empty, PartyACSP7 = string.Empty, PartyACSP8 = string.Empty, PartyACSP9 = string.Empty, PartyACSP10 = string.Empty; if (textboxValues != null) { PartyACSP1 = safeGetString(textboxValues, 0); PartyACSP2 = safeGetString(textboxValues, 1); PartyACSP3 = safeGetString(textboxValues, 2); PartyACSP4 = safeGetString(textboxValues, 3); PartyACSP5 = safeGetString(textboxValues, 4); PartyACSP6 = safeGetString(textboxValues, 5); PartyACSP7 = safeGetString(textboxValues, 6); PartyACSP8 = safeGetString(textboxValues, 7); PartyACSP9 = safeGetString(textboxValues, 8); PartyACSP10 = safeGetString(textboxValues, 9); } newISDAAgreement[Constants.PartyACSPColumn] = PartyACSP1; newISDAAgreement[Constants.PartyACSP2Column] = PartyACSP2; newISDAAgreement[Constants.PartyACSP3Column] = PartyACSP3; newISDAAgreement[Constants.PartyACSP4Column] = PartyACSP4; newISDAAgreement[Constants.PartyACSP5Column] = PartyACSP5; newISDAAgreement[Constants.PartyACSP6Column] = PartyACSP6; newISDAAgreement[Constants.PartyACSP7Column] = PartyACSP7; newISDAAgreement[Constants.PartyACSP8Column] = PartyACSP8; newISDAAgreement[Constants.PartyACSP9Column] = PartyACSP9; newISDAAgreement[Constants.PartyACSP10Column] = PartyACSP10; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload