So, if you have an arbitrary number of columns and when you submit the 
form you get:

form.align=left,left,...
form.dname=Agent Version,Allow Client,...

then you can do:

colCount = listLen(form.align);
xml = "";
for (i = 1;  i LTE colCount; i++) {
     xml &= "<column>";
     xml &= "<align>#listGetAt(form.align, i)#</align>";
     xml &= "<dname>#listGetAt(form.dname, i)#</dname>";
     ...
     xml &= "</column>";
}
xml = "<columns>#xml#</columns>";


On 12/14/11 8:43 PM, Tom Jones wrote:
> Hello,
> I have been searching all over cf-talk archives and on google and I don't see 
> a good example on how to save form data to a xml file.
>
> So what I'm doing right now is, I have a xml file and read that and then 
> display it in a form so the it can be edited. Here is an example on what I'm 
> thinking. What I'm struggling with is the form data is not returned as an 
> array of structs where I could easily create a xml file from, it's just coma 
> separated lists.
>
> Thanks,
> tom
>
> <!--- Example XML
> <columns>
>      <column>
>          <align>left</align>
>          <dname>Agent Version</dname>
>          <hidden>false</hidden>
>          <idx>2</idx>
>          <name>agent_version</name>
>          <order>2</order>
>          <width>100</width>
>      </column>
>      <column>
>          <align>left</align>
>          <dname>Allow Client</dname>
>          <hidden>false</hidden>
>          <idx>3</idx>
>          <name>AllowClient</name>
>          <order>1</order>
>          <width>100</width>
>      </column>
> </columns>
> --->
> <form name="colSettings" method="post">
> <table width="600" cellpadding="2" cellspacing="1">
> <tr>
>       <th>Order</th>
>       <th>Display Name</th>
>       <th>Align Text</th>
>       <th>Hide</th>
>       <th>Column Width</th>
> </tr>
> <cfloop index="x" array="#sortedColsArray#">
> <tr>
> <cfoutput>
>       <td><input type="text" name="order" size="3" value="#x.order#"></td>
>       <td><input type="text" name="dname" size="50" value="#x.dname#"></td>
>       <td><input type="text" name="align" size="10" value="#x.align#"></td>
>       <td><input type="text" name="hidden" size="3" value="#x.hidden#"></td>
>       <td><input type="text" name="width" size="10" value="#x.width#"></td>
> </cfoutput>   
> </tr>
> </cfloop>
> </table>
> <input name="submit" type="submit" value="Save" />
> </form>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:349158
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to