Notings of Attention™
Acmlmboard 2 Released
Github/GIT | @acmlmboard
Chatting Places
Discord

Affiliates
Super Mario Bros. X | Kuribo64 | NeoRHDN
Views: 11,030,476
Main | FAQ | IRC chat | Memberlist | Active users | Latest posts | Stats | Ranks | Online users | Search
11-21-24 11:53 AM
Guest: Register | Login

0 users currently in AcmlmBoard Developer Zone | 3 bots

Main - AcmlmBoard Developer Zone - FW: More Dynamic Method for Polls
Next newer thread | Next older thread


Emuz
Posted on 03-28-12 06:44 PM Link | ID: 10806
Site Administrator

11 Hit Combo:
Mother's Rosario
Level: 109


Posts: 630/3393
EXP: 13563465
Next: 396180

Since: 12-30-11
From: Akron, Ohio; USA

Last post: 114 days
Last view: 3 days
Sent by Mega-Mario
This is something I coded out of boredom. I figured you may be interested in it fo this board. Tested on Firefox, Chrome and IE, and works. Should work on Opera as well.

Basically, it suppresses the need of manually entering a number of options and hitting Preview. Instead, users can add or remove poll option fields directly.

I can give you the .js file directly: http://acmlm.kafuka.org/uploader/get.php?id=4135

However, this doesn't apply to the modified newthread.php. The one I used comes from the leaked AB2.0a1, I could guess about the multivote/changeable checkboxes, but I have no idea how thread tags work. So instead I'll be giving you the essential parts and telling you where they go.

$pollin=
"$L[TR]>
". " $L[TD1c]>Poll question:</td>
". " $L[TD2]>$L[INPt]=question size=60 maxlength=60 value=\"\"></td>
". "$L[TR]>
". " $L[TD1c]>Poll options:</td>
". " $L[TD2] id=polloptions>$L[INPh]=numopts id=numopts value=\"1\">
". " <div id=pollopt0>$L[INPt]=opt0 id=opt0 size=40 maxlength=40 value=\"\">"
." - RGB color: $L[INPt]=r0 id=r0 size=3 maxlength=3 value=\"".rand(0,255)."\">"
."$L[INPt]=g0 id=g0 size=3 maxlength=3 value=\"".rand(0,255)."\">"
."$L[INPt]=b0 id=b0 size=3 maxlength=3 value=\"".rand(0,255)."\"></div>
". " <input type=\"button\" id=optend value=\"Add option\" onclick=\"addOption(); return false;\">
". " </td>
". "$L[TR]>
". " $L[TD1c]>Poll settings:</td>
". " $L[TD2]>$L[INPc]=multivote value=1 id=mv><label for=mv>Allow multiple voting</label> | $L[INPc]=changeable checked value=1 id=ch><label for=ch>Allow changing one's vote</label>
";

$polljs=
"<script type=\"text/javascript\" src="\"dynapoll.js\"></script>". "<script type=\"text/javascript\">var numopts = 1;</script>
";

Replaces:
$pollin=
"$L[TR]>
". " $L[TD1c]>Poll question:</td>
". " $L[TD2]>$L[INPt]=question size=60 maxlength=60 value=\"".htmlval($_POST[question])."\"></td>
". "$L[TR]>
". " $L[TD1c]>Number of options:</td>
". " $L[TD2]>$L[INPt]=numopts size=2 maxlength=2 value=\"".htmlval($_POST[numopts])."\"><br><font class=sfont>Press Preview to update the number of fields displayed.</font></td>
". " $L[INPh]=noptcache value=0>
". "$L[TR]>
". " $L[TD1c]>Options:</td>
". " $L[TD2]>$L[INPc]=multivote value=1 id=mv><label for=mv>Allow multiple voting</label> | $L[INPc]=changeable checked value=1 id=ch><label for=ch>Allow changing one's vote</label>
";



$_POST[question]=stripslashes($_POST[question]);
$numopts=$_POST[numopts];
checknumeric($numopts);

for($i=0;$i<$numopts;++$i){
$_POST["opt$i"]=stripslashes($_POST["opt$i"]);
$pollin.="<div id=pollopt$i>$L[INPt]=opt$i id=opt$i size=40 maxlength=40 value=\"".htmlval($_POST["opt$i"])."\">"
." - RGB color: $L[INPt]=r$i id=r$i size=3 maxlength=3 value=\"".htmlval($_POST["r$i"])."\">"
."$L[INPt]=g$i id=g$i size=3 maxlength=3 value=\"".htmlval($_POST["g$i"])."\">"
."$L[INPt]=b$i id=b$i size=3 maxlength=3 value=\"".htmlval($_POST["b$i"])."\">";
if ($i > 0) $pollin.=" <a href="\"#\"" onclick=\"removeOption(this.parentNode); return false;\"><img src="\"img/delete.png\"></a>"; $pollin.="</div>";
}

$pollin=
"$L[TR]>
". " $L[TD1c]>Poll question:</td>
". " $L[TD2]>$L[INPt]=question size=60 maxlength=60 value=\"".htmlval($_POST[question])."\"></td>
". "$L[TR]>
". " $L[TD1c]>Poll options:</td>
". " $L[TD2] id=polloptions>$L[INPh]=numopts id=numopts value=\"$numopts\">
".$pollin."
". " <input type=\"button\" id=optend value=\"Add option\" onclick=\"addOption(); return false;\">
". " </td>
". "$L[TR]>
". " $L[TD1c]>Poll settings:</td>
". " $L[TD2]>$L[INPc]=multivote ".($_POST[multivote]?"checked ":"")."value=1 id=mv><label for=mv>Allow multiple voting</label> | $L[INPc]=changeable ".($_POST[changeable]?"checked ":"")."value=1 id=ch><label for=ch>Allow changing one's vote</label>
";

$polljs=
"<script type=\"text/javascript\" src="\"dynapoll.js\"></script>". "<script type=\"text/javascript\">var numopts = $numopts;</script>
";

Replaces:
$_POST[question]=stripslashes($_POST[question]);
$numopts=$_POST[numopts];
checknumeric($numopts);
$pollin=
"$L[TR]>
". " $L[TD1c]>Poll question:</td>
". " $L[TD2]>$L[INPt]=question size=60 maxlength=60 value=\"".htmlval($_POST[question])."\"></td>
". "$L[TR]>
". " $L[TD1c]>Number of options:</td>
". " $L[TD2]>$L[INPt]=numopts size=2 maxlength=2 value=\"".htmlval($_POST[numopts])."\"><br><font class=sfont>Press Preview to update the number of fields displayed.</font></td>
". " $L[INPh]=noptcache value=$numopts>
";
for($i=$noptcache;$i<$numopts;++$i){
$_POST["r$i"]=rand(0,255);
$_POST["g$i"]=rand(0,255);
$_POST["b$i"]=rand(0,255);
}
for($i=0;$i<$numopts;++$i){
$_POST["opt$i"]=stripslashes($_POST["opt$i"]);
$pollin.="$L[TR]>$L[TD1c]>Option ".($i+1).":</td>"
."$L[TD2] >$L[INPt]=opt$i size=40 maxlength=40 value=\"".htmlval($_POST["opt$i"])."\">"
." - RGB color: $L[INPt]=r$i size=3 maxlength=3 value=\"".htmlval($_POST["r$i"])."\">"
."$L[INPt]=g$i size=3 maxlength=3 value=\"".htmlval($_POST["g$i"])."\">"
."$L[INPt]=b$i size=3 maxlength=3 value=\"".htmlval($_POST["b$i"])."\">";
}
$pollin.="$L[TR]>
". " $L[TD1c]>Options:</td>
". " $L[TD2]>$L[INPc]=multivote ".($_POST[multivote]?"checked":"")." value=1 id=mv><label for=mv>Allow multiple voting</label> | $L[INPc]=changeable ".($_POST[changeable]?"checked":"")." value=1 id=ch><label for=ch>Allow changing one's vote</label>
";



". "<form action=\"newthread.php".($ispoll?"?ispoll=$ispoll":'')."\" method=post>
". " $L[TBL1]>

Replaces:
". "$L[TBL1]>
". " <form action=newthread.php?ispoll=$ispoll method=post>



". " $L[TBLend]
". "</form>
".$polljs."

Replaces:
". " </form>
". "$L[TBLend]



The reason <form> and <table> have to be switched around is that some browsers like Firefox don't like when a form is inside a table but contains the table's cells. In particular, what happens is that adding fields work, but the fields don't get sent with the rest of the POST request.

Sorry for the lengthy PM. Let me know if there are any issues with my code. I tested it and didn't find any, but we never know.



The Dynamic Profile Administratorâ„¢


"Never Knows Best"
Note: if you can see this my layout broke. ALL THE CREDITS WILL BE REVEALED!!
'Victory Noriko' by @thatsheepagain.
'Chibi Dance Noriko' by @Haru__Kitsu.
'Deity's Night Out (Featuring Gabbie)'
by @thatsheepagain
Noriko Emotes by @Haru__Kitsu.
Side Bar Noriko by @thatsheepagain
'Noriko's Nature Walk' by @projectTiGER_
Emotive Noriko by @thatsheepagain.
"Space Candy Noriko" by BerryVerrine.
"Super Sharp Noriko" by Xionfes.
A gift illustration from the wonderful EverKinzPony!
"Magical Girl Noriko" by @cute_hospital!
"Patient Chibi Noriko" by @Ruii_ki!
'Dapper '60s Noriko' by @thatsheepagain.
'Shiny Chibi Noriko' by @inioli.
'Flower Veil Noriko' by @Sushiee_.
'Noriko in Realism' by @_Sarybuu.
'Noriko's Midnight Adventure' by @projectTiGER_
'Yukata Noriko' by @yunyunmaru_
'Birthday Wishes Noriko' by @thatsheepagain

Next newer thread | Next older thread
Main - AcmlmBoard Developer Zone - FW: More Dynamic Method for Polls


Acmlmboard v2.5.6 (06/11/2024)
© 2005-2024 Acmlm, Emuz, et al.

Page rendered in 3.308 seconds. (789KB of memory used)
MySQL - queries: 51, rows: 481/515, time: 3.261 seconds.