I have a little problem where I need to generate a poll/survey template from a list of answers to be used in an email newsletter.
So - The poll is created in the CMS and answers are displayed in an ordered list. There's a text field in the list item where users input their answer. - Beneath the ordered list is a textarea with a button called "generate poll code" right beneath it - On clicking the button, javascript should generate the desired "template" with the Answers, Answer Ids and the Poll Id in anchor links with a query (as shown below).
So the ordered list markup is as following:
<ol id="9999">
<li id="1234"><input value="Answer1"/></li>
<li id="5678"><input value="Answer1"/></li>
<li id="9876"><input value="Answer1"/></li>
</ol>
Where the poll ID is the id of the ordered list and each li has the answer ID.
What I've been trying to get is this simple list of anchor links:
Poll question<br />
<a href="http://urlpath?pollId=9999&answerId="1234">Answer 1</a>
<a href="http://urlpath?pollId=9999&answerId="5678">Answer 1</a>
<a href="http://urlpath?pollId=9999&answerId="9876">Answer 1</a>
So basically, on click, iterate over the ordered list, grab the ids and then output the anchor list with the ids in the right places.
Just reduce this email, I haven't included my unsuccessful attempts at this, where I tried to use a for loop, get the Ids, store them in an array and then build the anchor link template with those injected.
Is there anyone who knows of good way to handle this and get the desired results
Very grateful for any assistance, THANK YOU!
- L