Hello,
I am trying to populate a unique list of input type=“checkbox” on a form from a custom field from channel entries.
They should return a list of {town}.
I am currently using a SQL query but with no luck.
Any advice?
{exp:email:contact_form user_recipients="no" recipients="[email protected]" charset="utf-8" channel="lettings|sales"}
<h2>Tenant Registration Form</h2>
<p> <br />
<label for="name">Your Name:</label></p>
<p> <input type="text" id="name" name="name" size="40" maxlength="35" value="" required autofocus="autofocus" autocomplete="yes" /><br />
</p>
<p> <br />
<label for="from">Your Email:</label></p>
<p> <input type="email" id="from" name="from" size="40" maxlength="35" value="" required autocomplete="yes" /><br />
<br />
<br />
<label for="from">Your Contact Number:</label></p>
<p> <input type="tel" id="number" name="number" size="40" maxlength="35" value="" autocomplete="yes" /><br />
<br />
<br />
<br />
<label for="bedrooms">Bedrooms:</label><br />
<input id="bedrooms-lettings" name="bedrooms" type="number" class="input-small" min="1" max="9" pattern="[0-9]*"><br />
<br />
<br />
<label for="locations">Locations</label><br />
{exp:query<br />
backspace="0"<br />
sql="<br />
SELECT DISTINCT<br />
d.field_id_3 AS town<br />
FROM<br />
exp_channel_data d,<br />
exp_channel_titles t,<br />
exp_channels c<br />
WHERE<br />
c.channel_name IN ('lettings', 'sales')<br />
AND<br />
c.channel_id = t.channel_id<br />
AND<br />
t.entry_id = d.entry_id<br />
AND<br />
t.status != 'closed'<br />
AND<br />
d.field_id_3 != ''<br />
ORDER BY town ASC<br />
"}<input type="checkbox" id="locations" name="location[]" value="{town}">{town}{/exp:query}<br />
<br />
<br />
<br />
<br />
<br />
<br />
<input name="submit" type='submit' value='Submit Form' class="btn" /><br />
<br />
{/exp:email:contact_form}