Click here to Skip to main content
15,879,844 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I need help on how to code, for an explain the answer to a question in an Online Examination project. want to code to work when you click a button named "explain", the explanation of the question and its answer will appear on the same page as the question. Please suggestions and links will be appreciated. Thank you.
Posted
Updated 28-Mar-13 1:20am
v3
Comments
bbirajdar 28-Mar-13 7:17am    
okk
ZurdoDev 28-Mar-13 7:22am    
Where are you stuck?
Hariharan Arunachalam 28-Mar-13 7:22am    
Have the explanations stored in a database as text/string.
Have a display field; use AJAX to get the explanations when required or use plain show/hide using javascript. Populate the explanations into the fields when rendering the page to the client. And you're done!!!
OsoJames 28-Mar-13 7:27am    
@ryanb31, i just had the idea but had no idea to go about.
@Hariharan, thanks for the idea i'll try it, it sounds good.
@aspnet_regiis -i, any suggestions or links. I need more options
Ankur\m/ 28-Mar-13 8:02am    
So did you do any basic research or searched Google for information on the subject?

1 solution

You can done this using two ways..

1. Using code behing
Just load explanation of the question in panel for each questions and set visibility="false".. When user clicks on explain button set panel visibility="true"..
Example :
Html below..
XML
<div>
        Question 1. what is object..?
        <br />
        Answer : Object is a instance of class
        <br />
        <asp:Button ID="Button1" runat="server" Text="explain" />
           <br />
        <asp:Panel ID="panel1" Visible="false" runat="server">
            A class or struct definition is like a blueprint that specifies what the type can
            do. An object is basically a block of memory that has been allocated and configured
            according to the blueprint. A program may create many objects of the same class.
            dynamically.
        </asp:Panel>
    </div>


Code behind..
VB
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        If panel1.Visible = True Then
            panel1.Visible = False
            Button1.Text = "explain"
        Else
            panel1.Visible = True
            Button1.Text = "Hide"
        End If

    End Sub



2. Using JQuery
script below..
HTML
<script src="js/jquery-1.4.2.js" type="text/javascript"></script>
   <script type="text/javascript">
   $(document).ready(function()
   {
       $("#div1").hide();
       $("#Button1").click(function()
       {
           $("#div1").toggle();
       });
   });
   </script>

Html below..
HTML
<div>
        Question 1. what is object..?
        <br />
        Answer : Object is a instance of class
        <br />
        <input id="Button1" type="button" value="explain" />
           <br />
        <div id="div1">
            A class or struct definition is like a blueprint that specifies what the type can
            do. An object is basically a block of memory that has been allocated and configured
            according to the blueprint. A program may create many objects of the same class.
        </div>
    </div>

See below link..
http://www.electrictoolbox.com/show-hide-element-with-jquery-part-1/[^]
 
Share this answer
 
Comments
OsoJames 28-Mar-13 8:11am    
Thank you very much vinodkumarnie for the help, i guess it would work perfectly
vinodkumarnie 28-Mar-13 8:21am    
Welcome.. Please have practice of giving rates and accepting answers if you got answer..
OsoJames 28-Mar-13 10:24am    
Thanks, its working just perfectly, i needed the idea, so i could apply it to the 'explain value' i retrieve from my database. Thanks for the advice
vinodkumarnie 28-Mar-13 11:26am    
You are most welcome... :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900