Hi all. I am fairly new here, so please pardon any blunders.
I have been reading about snippets and chunks and the bad, good, and better ways of creating pages using them. I have some dynamic database driven information (for example, a list of people that is updated periodically). I want to make a combo box containing all the people and (optionally) set one of the combo box entries as selected. The pseudo-code for this sort of thing might look like:
- Get stuff from the database
- Loop through the stuff from the database
- Add an option within the combo box for each element, and tag one if it is the selected one
I can see how to alter a chunk using [+my_var+]. However, I want to replace the set of option values as a whole, and I want maybe 1 of them to be selected. I also want to follow the sage advice about not outputting display elements directly in my snippet. This seems to lead me to have a tiny chunk that looks like <OPTION/>[+option_value+], another tiny chunk that looks like <OPTION "selected"/>[+option_value+], and use those to build up an option list which I replace in a chunk that looks like <SELECT name="[+some-name+]">[+option-list+]</SELECT>.
Is this the cleanest way to implement this?
Thanks in advance.
P
Have a look at the Wiki article linked to in my signature, that should get you started with your snippet and place holders for the chunk.
If you need more help post back.
Thanks bunk58. That is pretty much what I came up with. I was just unsure about using a chunk as simple as
<option [+selected+]/>[+option-value+]
to do the rendering. Much abridged (uh, obliged)
P