![]() |
| |||||||
![]() | « Previous Thread | Next Thread » |
| | LinkBack | Thread Tools | Display Modes |
| |||
| Hi, I have 18 questions for a quiz. Once one question is answered the second question is displayed when you answer the second question third question is displayed i want to show the progress bar at the bottom which shows them how many questions they answered so the progress bar will be from 0 to 100% completed i will have a gif which will expand every time a question is answered So when a user answers question one i store one in this variable noofanswers But when i display the gif image it shows me one instead of the image Code: <%
For int_Counter = 1 TO noofanswers
Response.Write("<script language=""JavaScript"">Progress.innerHTML='<img src=finalprogress.gif height=20 width=" & int_Counter * 2 & ">';</script>")
Response.Flush
Next
%>
|
| Sponsored Links |
| ||||
| Not sure, but first I would handle this a different way. Retrieve the total number of questions and the total number the user answered. Take the number answered and divide it by the number of questions. Then place that percentage as the width of the progress bar. So if a user has 10 questions but has only answered 4, the calculation would be 4/10 or 40%.
__________________ jmurrayhead Did I help you out? Make me popular by clicking the icon!If you found a post helpful, please click the button in the lower right-hand corner of the post.Powered by ASP.Net |
| |||
| tried it like this Code: totalquestions="18" widthofimage=noofanswers/totalquestions <img src="images/finalprogress.gif" height="20" width="<%=widthofimage%>"/> todd |
| ||||
| Are you sure noofanswers has a value? Also, assign actual numbers to your variables, not strings: Code: totalquestions="18" Code: totalquestions = 18 |
| |||
| thanks for your reply. here is the new code Code: totalquestions=18 Response.write "Total Questions:-" & totalquestions& "<br/>" Response.write "Answered Questions:-" & noofanswers& "<br/>" widthofimage=noofanswers/totalquestions*100 widthofimage=Round(widthofimage,2) <img src="images/finalprogress.gif" height="20" width="<%=widthofimage%>"/> Same thing the outout is 5.56 after a user answered question 1 todd |
| ||||
| What does this output? Code: totalquestions =18 Response.write "Total Questions:-" & totalquestions& "<br/>" Response.write "Answered Questions:-" & noofanswers& "<br/>" widthOfImage = (noOfAnswers/totalQuestions) <img src="images/finalprogress.gif" height="20" width="<% =FormatPercent(widthOfImage,0) %>"/> |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
| Sponsored Links |
| ASP.NET Resource Index a directory of ASP.NET tutorials, applications, scripts, assemblies and articles for the novice to professional developer. Free Web Directory Including Chats and Forums Resources, Offer automatic, instant and free directory submissions. | URLZ Web Directory URLZ Web Directory Free Web Directory - Add Your Link The Little Web Directory | Free Web Directory Pegasus free web directory is a free directory organised by categories. Web Directory & SEO Services dirroot web directory |