I am trying to dynamically update a form so that when you enter text into one text box other things on the form, like other text boxes change. This is such a common thing to want to do it seems like it ought to be easy but for some reason I haven't found the solution I tried things like
Here TheForm was a variable set to the form ID. I got the field list because in my form I have a variable number of fields and don't necessarily know the ID of each field. In this example I was just trying to set the first text box field on the form to "Test". That didn't work - the CIW echoed "Test" but the form didn't update.
Can anyone help show me how to update a form dynamically so that when one text field is changed by the user, another text field has its value changed?
You'd need to do:
If you just do car(TheForm->fieldList), you'll get the symbol which is the name of the field. What you were doing was setting a property on the symbol, not on the form field. So what I'm doing is getting the the form field structure itself, and then updating the value.
Note I would generally recommend against using fieldList - that's all very well until you then add a button or something else onto the form. Better would be to ensure that your fields are named deterministically by using something like concat('CLfieldThing count++) rather than gensym, and then record the number of fields on the form using TheForm->myFieldCount=count, or record the fields that you generate using TheForm->myFields=listOfFields. Note you can add whatever properties you like on the form data structure, so it's useful to store related information.
In reply to Andrew Beckett:
That works well. A very helpful response.