javascript retrieve value from created textbox

wo0ho0

New member
Joined
Dec 19, 2008
Messages
1
Programming Experience
Beginner
Hi guys, required some help here. This is my first time dealing with javascript and visual studio, so bear with me...

I have this chuck of code out in the net. I am confuse over how should i retrieve the value from the dynamic created textboxes from the code below. Any idea, similar snippet or code to retrieve?

Ex. i add 10 textbox, fill them up,and i wan all the value..then pass it back so that i could do backend code in vs to store in DB.

function addElementTextBox() {
//getting myDiv
var ni = document.getElementById('myDiv');
//Getting hidden text box value
var numi = document.getElementById('theValue');
//getting the hidden value and adding 1 into it
var num =parseInt(document.getElementById('theVa...
//Updating hidden text box value
numi.value = num;
//creating a new div
var newdiv = document.createElement('div');
//manuplating name of each div generated dynamically
var divIdName = 'my'+ num +'Div';
//setting the name of each div created dynamically
newdiv.setAttribute('id',divIdName);

//adding html text box dynamically into web page and paasing div name as argument in remove function
newdiv.innerHTML = '<input type=\"text\"name=\"'+divIdName+'\"> <a href=\'#\' onclick=\'removeElementTelephone("'+divI...

ni.appendChild(newdiv);

P.S: I had do some similar search but to no avail. Most of the answer are specifically using the searchbyNameTag of input where the above code is create and has unique id of divIdName for each textbox i suppose.

Thanks and regards.
 
first of all. what you are doing is creating a client-side control dynamically but not serverside contro. unfortunately you cannot create a server side control dynamically using merely javascript.

but you can try passing value to function created in server-side via scriptmanager of asp. <asp: ScriptManager ></asp>
 
Back
Top