General discussion


Contextual forms?

By pete ·
Anyone know of a form generator or code base (PHP or other Open Source solution) that allows one to build a form with remote proceedures (or just heavy DHTML) so that when you make a selection (Choose One: Option 1, Option 2, Option 3) then the next series of form elements are subs to that option
(Option 1a, Option 1b, Option 1c, Option 1aa, Option 2aa, Option 3aa, etc).

This way you can build forms with intelligence that lead the user, gently through even the most complex forms, while still maintaining low server overhead.



This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

Javascript code

by wwalsh100 In reply to Contextual forms?

i can only do this with two selection lists at the moment but working on it!!
this is how i did it

in the <head> section:
<script language="javascript" type="text/JavaScript">
function changeSearch(me, formName) <br/>{<br/>
if (me== '') return;<br/>
else {<br/>
var search = formName.Region;<br/>
switch (me) {<br/>
case "Spain":<br/>
search.options[0] = new Option ("Costa Brava" , "costa brava");<br/>
search.options[1] = new Option ("Barcelona" , "barcelona");<br/>
search.options[2] = new Option ("Costa Del Sol" , "costa del sol");<br/>
case "USA":<br/>
search.options[0] = new Option ("New York" , "new york");<br/>
search.options[1] = new Option ("Florida" , "florida");<br/>
search.options[2] = new Option ("Califonia" , "califonia");<br/>
search.options[0] = new Option ("Aegean Region" , "aegean");<br/>
search.options[1] = new Option ("Mediterranean Region" , "med");<br/>
search.options[2] = new Option ("Cappadocia" , "cappadocia");<br/>


then in the <body> of your page:<br/><br/>

<body onload="document.FormName.searchType.focus();">
<form id="FormName" action="" method="get" name="FormName"><br/>
<label for="searchType">Select Country</label><br/>
<select class="formSelect" name="searchType" id="searchType" size="1" tabindex="1" onchange="changeSearch(this.value, this.form);"><br/>
<option selected="selected">Choose </option><br/>
<option value="Spain">Spain</option><br/>
<option value="USA">USA</option><br/>
<option value="Turkey">Turkey</option><br/>
<label for="Region">Select Region</label><br/>
<select class="formSelect" name="Region" id="Region" size="1" tabindex="2"><br/>
<option selected="selected">Select a region</option><br/>

<label for="Keywords">Keywords</label><br/>
<input class="formInputField" type="text" name="Keywords" id="Keywords" size="26" maxlength="50" tabindex="4"/><br/>
<input class="formInputButton" type="submit" name="submitButtonName" id="submitButtonName" value="Send" tabindex="5"/><br/>


hope this helps!!<br/>

Collapse -

Client or server side?

by Tony Hopkinson In reply to Contextual forms?

Client side JavaScript / DHTML springs to mind, but it's a howling nightmare to build and maintain. While not having to go back and forth to a server is a potential bonus, having to put every potential variation in the HTML page gives an unweildy mess.

Server side (PHP et al), would depend on how granular the form would be, if the form is in sections and each one could be made page request, then you could minimise / remove the bloat.

You should be making the choice on how how often the form structure will change and how complex those changes are, especially if you need previous versions available.

If you have a lot of change to cope with, don't go near client side execution in web pages, you'll lose control in short order.

I'd recomend describing the form 'logic' with meta data and then building them based on that.

XForms might be worth looking at.

Delivery client or server side would depend how rich the functionality should be unless you fancy AJAX.

Related Discussions

Related Forums