Let's pave the right way as follows:
- Code: Select all
<select name="department" class="department" >
<option value="">Choose Location</option>
<option value="Location 1 (page-id #001)" >Location 1</option>
<option value="Location 2 (page-id #002)" >Location 2</option>
</select>
With above simplification let's assume that
location.php template has these 2 pages, and the embedded form is viewed on
page_view of each of these locations. it is getting clear that a simple conditional can be employed to find currently-viewed page to be marked as selected. Rewritten piece can look like this:
- Code: Select all
<cms:set current_page_id = k_page_id scope='global' /> - remember viewed page
<cms:pages masterpage='location.php' skip_custom_fields='1' >
<cms:if k_paginated_top >
<select name="department" class="department">
<option value="-">Choose Location</option>
</cms:if>
<cms:set selected =
"<cms:if current_page_id eq k_page_id >selected<cms:else /></cms:if>" scope='global' />
<option value="<cms:show k_page_id />" <cms:show selected /> ><cms:show k_page_title /></option>
<cms:if k_paginated_bottom ></select></cms:if>
</cms:pages>
It's an option though to try luck with cms:input.
- Code: Select all
<cms:set locations =
"
<cms:pages masterpage='location.php' >
<cms:if k_paginated_top >Select location = none | </cms:if>
<cms:show k_page_title /> = <cms:show email />
<cms:if k_paginated_bottom='0' >|</cms:if>
</cms:pages>
" scope='global' />
<cms:input
name='location'
type='dropdown'
class="department"
opt_values=locations
opt_selected=email />
The idea behind the above code is that each page has unique editable email in backend (if not - then unique page_id) which will become a selected dynamic option, depending on current visited page. Sending email would be trivial, as after submitting form the email will be available as
frm_location variable.
As long as the form is embedded into multitude of pages on website (footer or header seemingly?), then variable
email will match only for one of the 'location' pages (from
opt_values). For the rest of the website dropdown will ask for users's input instead.
Hope it helps.