SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Javascript & CF

  1. #1
    SitePoint Zealot eStudio's Avatar
    Join Date
    Dec 2001
    Location
    NE Texas
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript & CF

    I have found a Javascript that I would like to modify for use in my backend admin. It generates a table row, but instead of just generating a table row with the text, I'd like to generate a CFINPUT. I have "textarea" where I'd like to generate the CFINPUT if that helps any.

    Here's the code I've modified so far:

    <SCRIPT LANGUAGE="JavaScript">

    <!-- Begin
    function addRow(id){
    var tbody = document.getElementById
    (id).getElementsByTagName("TBODY")[0];
    var row = document.createElement("TR")
    var td1 = document.createElement("TD")
    td1.appendChild(document.createTextNode("textarea"))
    var td2 = document.createElement("TD")
    td2.appendChild(document.createTextNode("appmake"))
    var td3 = document.createElement("TD")
    td3.appendChild(document.createTextNode("appsku"))
    var td4 = document.createElement("TD")
    td4.appendChild(document.createTextNode("appcost"))
    var td5 = document.createElement("TD")
    td5.appendChild(document.createTextNode("appretail"))
    var td6 = document.createElement("TD")
    td6.appendChild(document.createTextNode("appsale"))
    var td7 = document.createElement("TD")
    td7.appendChild(document.createTextNode("appdesc"))
    var td8 = document.createElement("TD")
    td8.appendChild(document.createTextNode("apptype"))
    var td9 = document.createElement("TD")
    td9.appendChild(document.createTextNode("appshipweight"))
    var td10 = document.createElement("TD")
    td10.appendChild(document.createTextNode("appshipmethod"))
    row.appendChild(td1);
    row.appendChild(td2);
    row.appendChild(td3);
    row.appendChild(td4);
    row.appendChild(td5);
    row.appendChild(td6);
    row.appendChild(td7);
    row.appendChild(td8);
    row.appendChild(td9);
    row.appendChild(td10);
    tbody.appendChild(row);
    }
    // End -->
    </script>


    <a href="javascript:addRow('myTable')">add row</a>
    <p>
    <table id="myTable" cellspacing="0" border="1">
    <tbody>
    <tr>
    <td><b>appid</b></td>
    <td><b>appmake</b></td>
    <td><b>appsku</b></td>
    <td><b>appcost</b></td>
    <td><b>appretail</b></td>
    <td><b>appsale</b></td>
    <td><b>appdesc</b></td>
    <td><b>apptype</b></td>
    <td><b>appshipweight</b></td>
    <td><b>appshipmethod</b></td>
    </tr>
    </tbody>
    </table>

    Any help greatly appreciated. Already posted in the CF forum but no help so far. I don't know much about Javascript so a code example would help more than an explanation if possible.

    TIA,
    Donna

  2. #2
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You shouldn't be using createElements - use addRow and addCell - look at the methods for html in the reference for it of msdn.microsoft.com/library.

    Then you probably should be using an array and a for loop - you could destroy the length of code you're using considerably!

    td1.appendChild(document.createElement(TEXTAREA))

    But i wouldn't do it like that - as i said above - use references more.

    If you do want to know more - let me know - i'll go into deeper detail of it.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  3. #3
    SitePoint Zealot eStudio's Avatar
    Join Date
    Dec 2001
    Location
    NE Texas
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could you post some example code ?

    Going to the MSDN Library...

    Thanks,
    Donna


Bookmarks

Posting Permissions

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