/    Sign up×
Community /Pin to ProfileBookmark

creating dynamic forms

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

to post a comment
Full-stack Developer

8 Comments(s)

Copy linkTweet thisAlerts:
@RibeyedJan 26.2003 — 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
Copy linkTweet thisAlerts:
@mangeloniauthorJan 26.2003 — 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! ?

~MVA
Copy linkTweet thisAlerts:
@RibeyedJan 26.2003 — 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?
Copy linkTweet thisAlerts:
@mangeloniauthorJan 27.2003 — 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
Copy linkTweet thisAlerts:
@RibeyedJan 27.2003 — 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.



[U]tblAdministrators[/U]

AdminID*

AdminUserName

AdminPassword

[U]tblGuesser[/U]

GuesserID*

GuesserName


[U]tblParticipant[/U]

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.
Copy linkTweet thisAlerts:
@mangeloniauthorJan 28.2003 — ~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
Copy linkTweet thisAlerts:
@mangeloniauthorFeb 05.2003 — 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
Copy linkTweet thisAlerts:
@RibeyedFeb 05.2003 — 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.
×

Success!

Help @mangeloni spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...