Dynamically Load a Poll or Rating

To dynamically load a poll or a rating on a page, you first need to make sure the poll or rating HTML container markup is already loaded on that page.

Poll HTML container

<div id="PDI_container[poll-id]" class="PDS_Poll"></div>
<div id="PD_superContainer"></div>

The [poll-id] should be replaced with the id of the poll you want to load.

Rating HTML container

<div class="pd-rating" id="pd_rating_holder_[rating-id][item-id]"></div>

The [rating-id] should be replaced with the id of the rating you want to load.
The [item-id] is optional. If you are using an item id with your rating, you should place it here.

You can then proceed to load the poll or rating javascript library dynamically.

Load Libraries Dynamically with Javascript

var wp_pd_js = document.createElement( 'script' );
wp_pd_js.type = 'text/javascript';
wp_pd_js.src = 'http://static.polldaddy.com/p/[poll-id].js'; //For ratings - http://i.polldaddy.com/ratings/rating.js
wp_pd_js.async = true;
document.getElementsByTagName( 'head' )[0].appendChild( wp_pd_js );

The [poll-id] should be replaced with the id of the poll you want to load.

Polldaddy Tweets
%d bloggers like this: