The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> Dynamically add questions data to html page, creating a survey application that dynamically forms the HTML page
uahmed90
post Mar 26 2018, 03:23 PM
Post #1





Group: Members
Posts: 5
Joined: 26-March 18
Member No.: 26,614



Hi,

I'm working on a college project. I need to create a Survey application, and the part that I am stuck on is how to bring data into my html form from a database, dynamically?
Basically, there are questions, and the answers, which the user will choose and both the questions and answers will be submitted into a database. That much I can do, but I cannot figure out how to bring the question itself from the database, and make it appear in the HTML page. For example:

Question: <input type="text" id="ques">, this will give me the form field to input the answer to the question and program the submit button to send both question and answer to the database, but how do I RETRIEVE the QUESTION itself, from the database? the Question: <input type="text" id="ques">, this is what I want to bring in from the database.

Also, I am using a firebase database, so if possible, please answer in reference to that, if not thats no problem. I can figure that part out if I can understand how to do that in html.

THanks
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
 
Reply to this topicStart new topic
Replies
CharlesEF
post Mar 27 2018, 02:39 PM
Post #2


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



QUOTE(uahmed90 @ Mar 26 2018, 03:23 PM) *
Basically, there are questions, and the answers, which the user will choose and both the questions and answers will be submitted into a database. That much I can do, but I cannot figure out how to bring the question itself from the database, and make it appear in the HTML page. For example:
This statement makes me think you are using a server side language. What language is it, PHP ASP or ??? If you're putting data into a database then you must already know how to connect to the database, etc.

Your question is too broad unless you show us your code. How is your database setup? I think it would involve 2 tables, 1 table for questions and 1 table for answers. Each question needs to be tied to the possible answers (I assume you also have incorrect answers for each question). You don't want to store the correct answer in the web page because then you just need to 'View Source' to see the correct answer. This means that each question will have to make an AJAX call to retrieve the correct answer. I could go on but you get the idea.

Put some code together and post it here (or attach it to a post) with a specific question.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Mar 28 2018, 08:03 AM
Post #3


.
********

Group: WDG Moderators
Posts: 9,653
Joined: 10-August 06
Member No.: 7



QUOTE(CharlesEF @ Mar 27 2018, 09:39 PM) *

I think it would involve 2 tables, 1 table for questions and 1 table for answers.

Wouldn't one table suffice for that? Each question's row might contain one column each for the question and the answer alternatives. But maybe the chosen answer should be stored in a separate table, with one row for each participating user.

QUOTE
Each question needs to be tied to the possible answers (I assume you also have incorrect answers for each question). You don't want to store the correct answer in the web page because then you just need to 'View Source' to see the correct answer.

Note that it's a survey, not a user test, so I guess the answers must be shown for the user to see.

QUOTE
This means that each question will have to make an AJAX call to retrieve the correct answer.

That sounds like overkill to me, unless it's important to process each separate question one at the time (like in branching questions trees?). Otherwise the whole form could be submitted as a whole without Ajax.

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th April 2024 - 11:02 AM