www.webdeveloper.com
Results 1 to 2 of 2

Thread: How to Read dynamic text Area value from form?

  1. #1
    Join Date
    Dec 2008
    Posts
    1

    How to Read dynamic text Area value from form?

    Hi All
    I have a html form. I m creating a dynamic text area inside the form. I unable to get the dynamic text area value.

    code :
    =======
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <META NAME="Author" CONTENT="GGR">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    </HEAD>
    <script>

    var dynaSpellBoot="";
    var textName="";
    var tableRowIndex = 0;// need to change
    var rowIndex=0;

    function createCell(classNm, alignment)
    {
    newTd = document.createElement("<TD nowrap colspan=1>");
    newTd.className = classNm;
    newTd.setAttribute("align", alignment);


    return newTd;
    }
    function createRowAtIndex(tableObj, index, classNm, rowID, alignment)
    {
    var newTr = tableObj.insertRow(index);
    newTr.setAttribute("id", rowID);
    newTr.className = classNm;
    newTr.setAttribute("align", alignment);
    return newTr;
    }

    function createTextArea(tbName, defaultValue, classNm, styleId, rows, cols)
    {


    newTextArea = document.createElement("<TEXTAREA>");
    newTextArea.setAttribute("name", tbName);
    newTextArea.setAttribute("text", "dddd");
    newTextArea.setAttribute("value", "dddd");
    newTextArea.className = classNm;
    newTextArea.setAttribute("id", styleId);
    newTextArea.setAttribute("rows", rows);
    newTextArea.setAttribute("cols", cols);
    return newTextArea;
    }
    function createElement1(name,id)
    {
    rowIndex ++;
    var objTable = document.getElementById('textTable'); // need to change
    var newRow = createRowAtIndex(objTable,1,"tblBg2", '', 'center');// need to change
    tableRowIndex++;// need to change
    var commentsCell = createCell('cld', 'center');
    var commentsTxtArea = createTextArea(name, '', 'formInputs', id, 10, 15);// need to change
    commentsCell.appendChild(commentsTxtArea);// need to change
    newRow.appendChild(commentsCell);// need to change
    alert("Static Text area value ==>" + document.getElementsByName("aa.alist[0].comments")[0].value);
    alert("Dynamic Text area value ==>" + document.getElementsByName("aa.alist[1].comments")[1].value);
    // couldnt identified by ie.
    }

    </script>
    <BODY>
    <form name="textform" >
    <table>
    <tr>
    <td>
    <table>
    <tbody id="textTable">
    <tr><td>
    <textarea name="aa.alist[0].comments" rows="4" cols="20" size="170">
    Testing ... </textarea>
    </td></tr>
    </tbody>
    </table></td></tr></table>
    </form>
    </BODY>
    <script>
    createElement1("aa.alist[1].comments","genfac4");
    </script>
    </HTML>


    Run this code in ie. we can get text area value for static, not for dynamic.
    Can you please guide me to retreive the dynamic text area value from form ?
    Thanks in Advance!
    ggr

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    document.getElementsByTagName('textarea')[1].value
    Your script only works for IE, use standard methods to create elements.
    https://developer.mozilla.org/en/DOM....createElement
    http://alt-tag.com/blog/archives/2006/02/ie-dom-bugs/
    At least 98% of internet users' DNA is identical to that of chimpanzees

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles