SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
Thread: adding new text field
-
Jun 9, 2003, 05:33 #1
- Join Date
- Sep 2001
- Location
- Northern Virginia
- Posts
- 48
- Mentioned
- 0 Post(s)
- Tagged
- 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?
dan
-
Jun 10, 2003, 13:36 #2
- Join Date
- Aug 2001
- Location
- Los Angeles, CA
- Posts
- 346
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I wrote this script about a month ago for someone who wanted pretty much the same thing:
Code:<HTML> <HEAD> <Script language="JavaScript"> <!-- Written by: Greg Cook --> <!-- Website: http://www.html4me.com --> <!-- Email: host@html4me.com --> 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') { textboxNum++; textboxIndex = "textbox"+textboxNum; } else if (fieldType == 'checkbox') { checkboxNum++; checkboxIndex = "checkbox"+checkboxNum; } else if (fieldType == 'radio') { radioNum++; radioIndex = "radio"+radioNum; } document.getElementById("divTag" ).innerHTML += "<input type='"+fieldType+"' name='"+fieldName+"'>"; } // end of insertFE() function </script> </HEAD> <BODY> <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> </BODY> </HTML>
Bookmarks