| View previous topic :: View next topic |
| Author |
Message |
mcnika
Joined: 22 May 2008 Posts: 5
|
Posted: Mon Jun 30, 2008 2:44 pm Post subject: quick help |
|
|
Hi
I need a code in Ajax.
Suppose that there is a one text filed, by clicking on the button it must add one textfield too, then one more too and so on, by its own name. |
|
| Back to top |
|
 |
|
|
rangana 500+ Club

Joined: 27 Feb 2008 Posts: 626 Location: Cebu City Philippines
|
Posted: Tue Jul 01, 2008 1:44 am Post subject: Re: quick help |
|
|
Show us your attempt. Oh, and why AJAX? JS alone can do this for you  |
|
| Back to top |
|
 |
svmvishnu
Joined: 30 Jun 2008 Posts: 3
|
Posted: Tue Jul 01, 2008 7:01 am Post subject: Re: quick help |
|
|
Hi,
The following is code create a textarea dynamically(when u click the add button). what here i did is just duplicate the textarea and change its id.
<script>
var serial_number = 0;
function addTextArea()
{
container = document.getElementById("container");
div_ele = document.getElementById("test");
text_area = document.getElementById("sample");
div_ele.id = div_ele.id + "-" + serial_number;
text_area.id = text_area.id + "-" + serial_number;
div_ele.style.display = "";
container.appendChild(div_ele.cloneNode(true));
div_ele.id = "test";
text_area.id = "sample";
div_ele.style.display = "none";
serial_number++;
}
</script>
<div id = "container"> </div>
<div id = "test" style="display:none"> <textarea id = "sample"> </textarea> </div>
<input type = "button" value = "add" onClick = "addTextArea()">
Hope this meets your requirement.
~vishnu~ |
|
| Back to top |
|
 |
|