Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP poll, I can't get results to show in same layer

Status
Not open for further replies.

therunner

IS-IT--Management
Oct 16, 2002
2
GB
I'm new to web design and ASP, but I have an ASP poll which works perfectly and the results open in a seperate small pop up window.

However I want the results to display in a layer of the main page in place of the poll questions.

At the moment the whole of the main page is replaced by the results, what am I doing wrong?

Below is a simplification of the main page, in poll_ques.asp a submit button opens the database update page which then redirects to the results.asp page

Please can anyone help?

<html>
<head>
<title>Poll Frenzy</title>
</head>
<body>
<b>Today's poll</b>
<!-- #include file=&quot;poll_ques.asp&quot;-->

</body>
</html>
 
&quot;Below is a simplification of the main page&quot;. I'll say! Not a heck of a lot to go on either.
 
Thanks for the quick reply Veep.
I'd taken most of the html out of the main page, as it's fine, it's just the include that doesn't seem to work.

I've put the code for the questions, updating and results pages below.

Should the main page have the include in a layer and should I use javascript to change the content?
As the ASP works fine if I just open poll_ques.asp, should I have posted this in the html forum?

POLL_QUES.ASP

<!-- #include file=&quot;dbase_connect&quot;-->

<%
call dbsetup(&quot;\data\poll.mdb&quot;,oConn)
sql=&quot;select id,question from poll order by id desc&quot;
set RS=oConn.Execute(sql)
%>

<table border=&quot;0&quot;>

<% if not RS.BOF and not RS.EOF then%>
<tr>
<td><b><%=RS(&quot;question&quot;)%></b></td>
</tr>

<%
sql2=&quot;select poll_option from options where poll_id=&quot; & RS(&quot;id&quot;)
set RS2=oConn.Execute(sql2)%>

<form method=&quot;POST&quot; action=&quot;poll_update.asp&quot; target=&quot;_self&quot;>
<input type=&quot;hidden&quot; name=&quot;id&quot; value=&quot;<%=RS(&quot;id&quot;)%>&quot;>

<%while not RS2.BOF and not RS2.EOF%>
<tr>
<td><%=RS2(&quot;poll_option&quot;)%></td>
<td><input type=&quot;radio&quot; name=&quot;option&quot; value=&quot;<%=RS2(&quot;poll_option&quot;)%>&quot;></td>
</tr>
<%RS2.movenext
wend%>

<tr>
<td colspan=&quot;2&quot;><input type=&quot;submit&quot; value=&quot;Vote&quot;></td>
</tr>
</form>
<%end if%>
<tr>


<td colspan=&quot;2&quot;><a href=&quot;#&quot; onclick=&quot;window.open('results.asp?id=<%=RS(&quot;id&quot;)%>','','width=300,height=300')&quot;>view results</a></td>
</tr>
</table>



POLL_UPDATE.ASP

<!-- #include file=&quot;dbase_connect.asp&quot;-->

<%
call dbsetup(&quot;\data\poll.mdb&quot;,oConn)
sql=&quot;select votes from options where poll_id=&quot; & request(&quot;id&quot;)& &quot; and poll_option='&quot; & request(&quot;option&quot;) &&quot;'&quot;
set RS=oConn.Execute(sql)

sql2=&quot;update options set votes = &quot;& RS(&quot;votes&quot;) + 1 & &quot; where poll_id=&quot; & request(&quot;id&quot;) & &quot; and poll_option = '&quot; & request(&quot;option&quot;) & &quot;'&quot;

set RS2=oConn.Execute(sql2)

response.redirect(&quot;results.asp?id=&quot; & request(&quot;id&quot;))
%>

RESULTS.ASP


<!-- #include file=&quot;db_conn.asp&quot;-->
<!--display the results of the poll -->

<%
call dbsetup(&quot;\data\poll.mdb&quot;,oConn)
sql=&quot;select id, question from poll where id=&quot; & Request(&quot;id&quot;)
set RS=oConn.Execute(sql)
%>
<table border=&quot;0&quot;>
<% if not RS.BOF and not RS.EOF then%>
<tr>
<td><b><%=RS(&quot;question&quot;)%></b></td>
</tr>

<%
sql3=&quot;select sum(options.votes) as sumofvotes from options where poll_id=&quot; & RS(&quot;id&quot;)
set RS3=oConn.Execute(sql3)

sql2=&quot;select poll_option, votes from options where poll_id=&quot; & RS(&quot;id&quot;)
set RS2=oConn.Execute(sql2)

while not RS2.BOF and not RS2.EOF%>
<%dim votepercent, votevalue%>

<%if RS3(&quot;sumofvotes&quot;)<>0 then
votepercent=formatnumber(100*(RS2(&quot;votes&quot;)/RS3(&quot;sumofvotes&quot;)),2)
else
votepercent=0
end if
votevalue=RS2(&quot;votes&quot;)
%>
<tr>
<td><%=RS2(&quot;poll_option&quot;)%></td><td><%=votepercent%></td>
<td><img src=&quot;pixel.gif&quot; height=&quot;10&quot; width=&quot;<%=votepercent*1.5%>&quot; style=&quot;background-color:red&quot;></td>
</tr>
<%RS2.movenext
wend%>
<%end if%>
</table>
 
Let me make sure that I understand...The Poll_Update.asp page redirects the user to Results.asp. But you want to still be on Poll_Ques.asp and imbed the results into a layer? If that's the case then there's some retooling to do. The Poll_Ques.asp page posts to Poll_Update.asp which redirects to Results.asp. There are a variety of ways to do this but I think they all require either putting all of the code in one page (Poll_Ques.asp) or at least putting Results.asp into Poll_Ques.asp in an IF block. But, that's only if I'm getting it. ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top