ColdFusion Programming/CF Copy Text Field to another Text Field
Expert: Donald Hammond - 11/13/2008
QuestionI have a large form where I enable the user to submit quite a bit of data. One particular field requires the user input the GPS coordinates of an event. These coordinate must be converted to a different format. I have included the tool that allows the user to enter the data and upon clicking the "Calculate" button, the form displays the converted information in a new text field.
What I am wanting to do is take the information that is displayed in this text field, and have it populate another text field within a form that can be submitted with the remaining data entered into the form.
My question. How do I have ColdFusion grab the data from one text field and instantly display it in another for form submission?
Thanks
AnswerYou can not do this in ColdFusion because CF is a server side language and so you have to use JavaScript since it is a client side language.
You have to make your calculate button run a very simple javascript that reads one text field and populates the second after doing the calculation.
If you search the Javascript sites you can find many ways to do this. Basically it is
var myString = document.findElementByID("TxBox1").value;
// do your calculations on myString
document.findElementByID("TxBox2").value = myString;