Edi Weitz wrote:
Could you provide an example of what you're trying to do?
I have something like this, and the <option> tag needs to be selected when id matches the value of the parameter called location-id.
<p><label for="location-id">Location: </label> <select id="location-id" name="location-id"> <option value="">Choose a location</option> <!-- tmpl_loop rows --> <!-- tmpl_loop cols --> <option value="<!-- tmpl_var id -->"> <!-- tmpl_var name --></option> <!-- /tmpl_loop --> <!-- /tmpl_loop --> </select></p>
So I followed Igor's advice (thank you!) and changed the <option> tag above to this:
<option <!-- tmpl_var selected --> value="<!-- tmpl_var id -->"> <!-- tmpl_var name --></option>
Supported by this code:
(rows (loop for locationl in locations collect (list :cols (loop for location in locationl if (and (required-exist-p location-id) (equal (parse-integer location-id :junk-allowed t) (id location))) collect (list :id (id location) :name (name location) :selected "selected") else collect (list :id (id location) :name (name location)))))
It's working now. Do let me know if there are better ways to achieve this.
Vamsee.