PDA

View Full Version : Dynamic Form generation based on user selection.


NEExt
02-10-2005, 06:23 PM
I'm trying to design a "ticking system" to support about 1300 users for various frequently encountered problems with 10ish different internal systems we use here at work. I have a database table set up and I want to insert certain fields into it, depending on the type of problem the ticket creator is encountering. This database currently contains around 50 different fields.

If user selects Problem1, I want maybe 10 form fields to generate on a new page, require the user to fill out only those 10 fields, and then insert them into the DB table. If user selects Problem2, I want a totally seperate 10 fields to generate on a new page and require completion of those. If user selects Problem3, I maybe want 30 fields to generate. You get the picture.

Ideally i would like to do this on one ASP page that dynamically generates the form <inputs> based on a querystring that is passed by what type of problem the user clicked. I've racked my brain and tried a number of different things, none of which are working as intended.

I think the solution is to have a seperate table that holds what form components are needed for each possible user ticket choice, query that information using the querystring and then using the returned recordset, write out the form components. Does this sound right? Is there a better way?

Thanks in advance.

tboss132
02-10-2005, 07:54 PM
Use Select Case statement


<%
Select Case Problemtype
Case "Problem1"
%>
<form name="form1" method="post" action="">
<input type="text" name="textfield">
<input type="text" name="textfield2">
<input type="text" name="textfield3">
<!-- Other input types as you require
</form>
<%
Case "Problem2"
%>
<form name="form1" method="post" action="">
<input type="text" name="textfield">
<input type="text" name="textfield2">
<input type="text" name="textfield3">
<!-- Other input types as you require
</form>
<%
Case "Problem 3"
%>
<form name="form1" method="post" action="">
<input type="text" name="textfield">
<input type="text" name="textfield2">
<input type="text" name="textfield3">
<!-- Other input types as you require
</form>
<%
End Select
%>


See More about the Select Case statement here (http://www.w3schools.com/vbscript/vbscript_conditionals.asp)

NEExt
02-10-2005, 08:09 PM
Excellent! Thank you.. and here I was trying to make it far more difficult than it actually was.

tboss132
02-10-2005, 08:21 PM
NP. Glad to be of help NEExt