Click to See Complete Forum and Search --> : creating dynamic forms


mangeloni
01-21-2003, 09:58 PM
I just need a hint about what to do about creating dynamic forms...

This form would be based upon what an administrator has set in a 'preferences' table, then the 'user' would only see a form as the administrator has set it, but would write to another table upon onSubmit:

-If fieldA has valueA, display the valueA as text.
-If fieldA has valueB, display a textboxfield.
-If fieldA has valueC, display fieldC and fieldD as radio buttons.

I am using JavaScript/ASP and don't know if it can be handled in JavaScript/ASP...but am open to other languages/techniques. I don't know if this could be handled better in VB, DOM, XML...? I want to use the most efficient and flexible technique as I am not sure JavaScript is the best way to handle this. Looking for some opinions...

Thanks!

~MVA

Ribeyed
01-25-2003, 08:04 PM
ok i can help you.
what you are trying to do can be done using some lines of ASP.
please check to make sure you are ok with using ASP before i type you out some code, thanks

mangeloni
01-26-2003, 04:47 PM
Your help would be great. I am personally new at coding in Javascript and ASP. However, I have led many online development teams in applications using these - so I know the basic concepts, etc.

Fire away! :cool:

~MVA

Ribeyed
01-26-2003, 05:10 PM
ok np, what database are you using?

do you have a database structure for this? like do you know what you want to store about each type of preferance, and have created tables in a database for this?

how long have you got to build this?

mangeloni
01-26-2003, 10:00 PM
I am using Access at the moment (hoping to change to SQL later as my experience develops). I have 3 tables up and running at the moment (all have key fields and are linked to one another):

-Administrators (general contact information), 1 record per administrator login
-Guesser (preferences administrator sets for their questionaire), 1 record per administrator login
-Participants (where answers are stored for each participant), many records to a single Guesser record

The Administration and Guesser setup forms are up and running, and working with their respective tables. What I need to do is display a Participant Form based upon the values entered in the Guesser table.

For example:
Guesser Setup form:
Q1 pref)
(radioA1) I the participants to Know X >> menuB[It's Round /or/ It's Square]
(radioA2) I want to participants to Guess X

Result in Participant form (drawing from preferences set in Guesser table, but writes to Participants table):
Q1 question)
if fieldradioA = Know, then display menufieldB as text {this would not give the participant the ability to answer this question, just know the answer already}
else fieldradioA = Guess, then display form field radios (o) It's Round and (o) It's Square {this would give the participant the ability to make a choice}

Q2 is similar to this - so let's start with Q1, we can get into this later if I need to.

Q3 gives the Administrator the ability to choose (o) Imperial measurements -or- (o) Metric measurements. The result would be to display a menu of the chosen measurement choices to the participant. I think I know how this works, as it will have to display a separate table available measurment choices (1 table for Imperial, 1 table for Metric).

Your help is greatly appreciated!

~MVA

Ribeyed
01-27-2003, 04:03 AM
hi,
ok Access is find for what your trying to do. Just to get a few things straight in my haed fro what your trying to do.
I feel that the key to getting this like this working properly is good database developement. If your backend sucks that your code for manipulating your database will suck.
From the information you have given, your have the foloowing 3 tables.



tblAdministrators

AdminID*
AdminUserName
AdminPassword

tblGuesser

GuesserID*
GuesserName


tblParticipant

PartID*
PartName

Ok i need to know what other fields you have in these 3 tables.

Is there a relationship between the administrastor and guesser?
if so can an administrator have a relationship with 1 or more guesser?
Can a guesser have a relationship with more than 1 administrator?
you say that there is also a relationhip between the Guesser and the Participants, if so can 1 or more Participants have a relationship with a guesser?
Does the guesser have 1 or more partcipants?

Once I understand your structure and your concept I would post you some code to do this task.

mangeloni
01-27-2003, 08:16 PM
~Admin Table~
UserName*
Password
CreateDate
LastName
FirstName
...goes on to other contact info fields...

~Guesser~
GuesserNumber*
UserName (different from above, given to participants)
Password ("ditto")
Status
AdminUN (1 to 1 link to Admin UserName)
...goes on to the preferences fields...

~Participants~
PartNumber*
GuesserNumb (many to 1 link to Guesser Number)
...goes on to basic contact info fields...
...goes on to guesses/choices fields...

There is 1 Administrator to 1 Guesser, vice versa.
There is 1 Guesser to many Participants, vice versa.

~MVA

mangeloni
02-04-2003, 09:53 PM
David---

Don't worry about the database - that is all worked out.

Here are some specifics of the first thing I have to do....

If Color=Know
then response.write "It's <KnowColor.value>!"
{if the field Color has the value 'know' then display text and the value in the field KnowColor}
else Color=Guess
then response.write "I think the color is [ (o)Red (o)Blue ]
{if the field Color has the value 'guess' then display text followed by 2 radio button options}

*the fields 'Color' and 'KnowColor' are coming from the recordset "GuesserRecord" from the Guesser table

**the (o)Red (o)Blue radios will be writing to the 'Color' field in the Participants table

I hope this is specific enough.

~MVA

Ribeyed
02-05-2003, 04:40 AM
hi,
first of all In your Admin table you need to change your primary key from username to AdminID or something l;ike that, not a good idea to have text strings as primary keys.

ok so you would have an admin number retrieved from some where to start with. Maybe a drop down menu with the admin names or maybe the admin number comes from the login or cookie or something.
so you would start:
<%
AdminID = request.form("AdminID")

sqltext = "SELECT tblGuesser.GuesserID, tblGuesser.AdminID FROM tblGuesser WHERE tblGuesserID = "&AdminID&""

set RS = YourDB.Execute(sqltext)
GuesserID = RS.("GuesserID")
RS.Close
Set RS = nothing
thissql = "SELECT * FROM tblParticipants WHERE tblParticipants.GuesserID = "&GuesserID&""

set RS = YourDB.Execute(thissql)

theColour = RS("Colour")

If Colour = "Know" then

response.write "It's "&Colour&""
Elseif theColour = "Guess" then

response.write "I think the colour is: "%>

<input name="colour" type="radio" value="red"> Red <BR>
<input name="colour" type="radio" value="Blue"> <BR>

<%
end if
end if

RS.Close
set RS = nothing


%>
hope this helps.
p.s
you can just do this using 1 SQL statement, but i have just did it with 2 so you get the idea.