folks.. i have a simple table having two fields “Author ” and “Title”. Now One title can have many authors. So with authors, i have a button “Add”. OnClick(), i call a function which adds an element (textField) to it.
Now problem is that the text field added is placed randomly and not just below the Author Field
My Code is
<script>
var element=null;
var my_div=null
try {
element = document.createElement(“<input name=’a’ type=’text’ />”);
} catch (e) {
element = document.createElement(“input”);
element.setAttribute(“name”, “a1”);
element.setAttribute(“type”, “text”);
// element.setAttribute(“align”,”center”);
}
try{
my_div = document.forms[0].getElementById(“author”);
}catch(e){}
document.forms[0].insertBefore(element, my_div);
return element;
</script>
<table border=”0″>
<tr>
<td>Author</td>
<td> <input text=”text” name=”author” id=”author”/> </td>
<td><input type=”button” name=”btn” id=”btn” value=”Add” onclick=” return AddAuthor()”/></td>
<tr>
<td>Title</title>
<td> <input text=”text” name=”title” id=”title”/><td>
</tr>
</table>
Is it possible that when i click the “Add” Button, the new text field should
be placed just below the previous one and the second text field (Title) should automatically align itself?
Looking forward to reply