im asking the user to enter the number of fields he want to generate and i need to take this number and generate him the fields when he click Submit
can anyone Help Me
you mean dynamic text box generation...
or
what do you mean by fields here?
yeah thats what i mean dynamic text box generation
hello..
try this code:
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Third Santor</title>
<script>
function generate(){
var myDiv = document.getElementById('someid');
var objTextArea = document.getElementById('mem1');
var list = objTextArea.value.split('\n');
var tbody = document.createElement('tbody');
for(var i=0; i<list.length; i++){
var cell1 = document.createElement('td');
var label = document.createTextNode(list[i]);
cell1.appendChild(label);
var cell2 = document.createElement('td');
var textbox = document.createElement('input');
textbox.type = 'text';
textbox.id = list[i];
cell1.appendChild(textbox);
var row = document.createElement('tr');
row.appendChild(cell1);
row.appendChild(cell2);
tbody.appendChild(row);
}
var table = document.createElement('table');
table.border = 1;
table.appendChild(tbody);
/* var submit = document.createElement('input');
submit.type = 'submit';
submit.value = 'Submit';
*/
myDiv.appendChild(table);
myDiv.appendChild(submit);
}
</script>
</head>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<form name="frm1" method="post" action="" onsubmit="return ">
<textarea name="mem1" id="mem1" rows="10" cols="30"></textarea>
<input type="button" value="Generate" onclick="generate();">
</form>
<DIV id="someid"></DIV>
</body>
</html>
and also check:
http://www.daniweb.com/forums/thread135356.html
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.