SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2001
    Northern Virginia
    0 Post(s)
    0 Thread(s)

    adding new text field

    So I am a cold fusion developer and I need to add a new text field and/or a new set of text fields when i click on a button. I have certain amount of rows that each display data about an object. if more data needs to be stored than there are lines, the user needs to be able to dynamically add new text fields to type the data into. I don't want to have to refresh the page to do this since there could be data lost when the new text field line is added.

    also is it easier to create a scroll bar for this data in cold fusion than in js? I will display 5 lines, but if the user needs to add the sixth, they need to be able to scroll through all the 6 lines.

    can anyone please help me with this problem?


  2. #2
    SitePoint Addict
    Join Date
    Aug 2001
    Los Angeles, CA
    0 Post(s)
    0 Thread(s)
    I wrote this script about a month ago for someone who wanted pretty much the same thing:
    <Script language="JavaScript">
    <!-- Written by: Greg Cook -->
    <!-- Website: -->
    <!-- Email: -->
    var textboxNum = 0;
    var checkboxNum = 0;
    var radioNum = 0;
    var textboxIndex = "textbox"+textboxNum;
    var checkboxIndex = "checkbox"+checkboxNum;
    var radioIndex = "radio"+radioNum;
    function insertFE(fieldType, fieldName)
    if (fieldType == 'textbox')
    textboxIndex = "textbox"+textboxNum;
    else if (fieldType == 'checkbox')
    checkboxIndex = "checkbox"+checkboxNum;
    else if (fieldType == 'radio')
    radioIndex = "radio"+radioNum;
    document.getElementById("divTag" ).innerHTML += "<input type='"+fieldType+"' name='"+fieldName+"'>";
    } // end of insertFE() function
    <form name="form1"><div id="divTag"></div></form>
    <input type="button" value="Add a textbox!" OnClick="insertFE('textbox', textboxIndex)"><BR><BR>
    <input type="button" value="Add a checkbox!" OnClick="insertFE('checkbox', checkboxIndex)"><BR><BR>
    <input type="button" value="Add a radio button!" OnClick="insertFE('radio', radioIndex)"><BR><BR>
    This script basically adds a text box, a checkbox, or a radio button (depending on which button you click). Hopefully this helps...


Posting Permissions

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