/    Sign up×
Community /Pin to ProfileBookmark

problem with poll

There is a online poll in my website, user will select their choice by checking the radio button and click on the submit buuton, then a popup window will appear to display the result. how can i get the value of the radio button that have been checked and pass it to a php script?

to post a comment
JavaScript

11 Comments(s)

Copy linkTweet thisAlerts:
@JonaSep 08.2004 — [font=trebuchet ms]Loop through the elements; if it's a radio button, and it's checked, return its value. Send it to PHP by opening the new window with a query string (something like [/font][font=courier new]window.open('results.php?vote='+getVote()[/font][font=trebuchet ms]).[/font]
Copy linkTweet thisAlerts:
@robertngoauthorSep 08.2004 — how to detect in a element is radio button?
Copy linkTweet thisAlerts:
@JonaSep 08.2004 — <i>
</i>&lt;script type="text/javascript"&gt;
function submitForm(f){
var elems = f.elements;
var accn = "";
for(var i=0; i&lt;elems.length; ++i){
if(elems[i].type == "radio"
&amp;&amp;elems[i].checked){
accn = "?vote="+elems[i].value;
}
}
f.action += accn;
}
&lt;/script&gt;


<i>
</i>&lt;form action="vote.php" method="get" onsubmit="submitForm(this);" target="_child"&gt;
Copy linkTweet thisAlerts:
@robertngoauthorSep 08.2004 — thanks a lot for ur help
Copy linkTweet thisAlerts:
@robertngoauthorSep 08.2004 — i use window.open() to display the poll result but it does not work in mozilla firefox
Copy linkTweet thisAlerts:
@JonaSep 08.2004 — [font=trebuchet ms]Can you show me the page you have?[/font]
Copy linkTweet thisAlerts:
@robertngoauthorSep 09.2004 — the website is on my company server, i cannot be access without password.
Copy linkTweet thisAlerts:
@robertngoauthorSep 09.2004 — this is to code that i use

$poll .= " onClick="var opt=which(this.form); window.open('../poll.php?schid=".$schid."&permit=1&pollid=".$dbpoll[1]['pollid']."&answ='+opt,'','menubar=no,width=250,height=230');">

which() return the value of radio button that have been checked
Copy linkTweet thisAlerts:
@JonaSep 09.2004 — [font=trebuchet ms]If I can see it online, upload the relevant files at a *.zip file, because just posting segments of the code will get us nowhere and this thread will become exceedingly and unnecessarily lengthy.[/font]
Copy linkTweet thisAlerts:
@robertngoauthorSep 10.2004 — i have solve the problem by using + to concat the string, thanks for all ur help
Copy linkTweet thisAlerts:
@JonaSep 10.2004 — [font=trebuchet ms]Welcome.[/font]
×

Success!

Help @robertngo spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...