javascript - Generate poll/survey code from ordered list of answers to be used in email newsletter -
i have little problem need generate poll/survey template list of answers used in email newsletter.
so - poll created in cms , answers displayed in ordered list. there's text field in list item users input answer. - beneath ordered list textarea button called "generate poll code" right beneath - on clicking button, javascript should generate desired "template" answers, answer ids , poll id in anchor links query (as shown below).
so ordered list markup 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 poll id id of ordered list , each li has answer id.
what i've been trying 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 on ordered list, grab ids , output anchor list ids in right places.
just reduce email, haven't included unsuccessful attempts @ this, tried use loop, ids, store them in array , build anchor link template injected.
is there knows of way handle , desired results
very grateful assistance, thank you!
- l
you can loop on each list item using .each , output html each item.
//use .each loop on each li $('#9999 li').each(function(){ //for each li, id , val var li_id = $(this).attr('id'); var inp_val = $(this).find('input').val(); //append somewhere , drop values in $('#output').append('<a href="http://urlpath?pollid=9999&answerid=' + li_id + '">' + inp_val + '</a><br>' ); });
working example: http://jsfiddle.net/omgo/fthq9/2/
Comments
Post a Comment