Javascript poll code

Hello,

I have a site that provides free polls & quizzes for webmasters. I have 2 types of codes that my members use to put the poll or quiz on their webpage.

The first code is the “normal enbedded code”. When someone submit their vote, they will be taken to my site to view the current results. The code looks something like this:


<FORM ACTION="[http://www.ballot-box.net/vote.php](http://www.ballot-box.net/vote.php)" METHOD="post">
<INPUT TYPE="hidden" NAME="poll" VALUE="56030">
 
etc. etc.
 
<INPUT TYPE="submit" VALUE="Submit Vote">
</FORM>			 

The second code is the “popup embedded code”. When someone submit their vote, a popup window will open with the current results. The code looks something like this:


<SCRIPT TYPE="text/javascript">
<!-- start hide content from old browsers
function Start(page)
{OpenWin = this.open(page,"popup","scrollbars=1,top=50,left=100,width=560,height=450");}
// end hide content from old browsers -->
</SCRIPT>
<FORM ACTION="[http://www.ballot-box.net/vote.php](http://www.ballot-box.net/vote.php)" METHOD="post" TARGET="popup">
<INPUT TYPE="hidden" NAME="poll" VALUE="56030">
 
etc. etc.
 
<INPUT TYPE="submit" VALUE="Submit Vote" OnClick="Start('')">
</FORM>			 

Both codes seems to be working fine.

I don’t want my members to cut and paste the code on their site everytime they update the question and/or answers of their poll. That’s why I want to create a Javascript code that will automatically display the poll on the members site.

For nomal embedded code I have the following code:


<script language="JavaScript" src="[http://www.ballot-box.net/script.php?poll=56030"></script](http://www.ballot-box.net/script.php?poll=56030)>

The code for the script.php above will look something like this


document.writeln("<FORM ACTION=\\"[http://www.ballot-box.net/vote.php\\](http://www.ballot-box.net/vote.php/)" METHOD=\\"post\\">");
document.writeln("<INPUT TYPE=\\"hidden\\" NAME=\\"poll\\" VALUE=\\"56030\\">");
 
etc. etc.
 
document.writeln("<INPUT TYPE=\\"submit\\" VALUE=\\"Submit Vote\\">");
document.writeln("</FORM>");

This seems to work fine for the normal embedded version. But how do I create a code like this for the popup embedded code? Keep in mind that the popup embedded code displays the results in a popup window!

Just an idea (not sure if I completely understand)…

Take all the code from your original ‘popup embedded code’ and put it all in script.php, and document.write() it into the document.