PDA

View Full Version : Q&A Form. Is there a better way to do this?


Basscyst
08-01-2003, 02:11 AM
This code is a bit long here is a URL to it or see the attached text file. Again I have this working, but it's kind of a mess.
www.sacspots.com/array2.html
Basically it goes through a bunch of Q&A and then eMails your responses.

Basscyst
08-01-2003, 04:13 AM
Perhaps I should be more specific. I racked my brain on how to do this with a loop so I would only have to specify the HTML once, but never suceeded. It would be way easier to edit if I had just the questions themselves within the array. Some of the questions are yes and no. Some require further input from the user. On some you just press OK. Somtimes a Yes response will bring you to the next question, somtimes it will bring you to the solution. If it was all yes, no It would be a piece of cake. Perhaps it still is and I'm missing it. Oh and here is the file.

Vincent Puglia
08-01-2003, 06:24 PM
Hi,

it's kind of a mess

:)

pick out a table format for you main div. make it large enough so that you can drop in yes, no, maybe, text fields, etc. and that the same objects always fall into the same cells. Insert a div into each appropriate cell (not every, because you will probably want some spacing).

<div id=main...
<table...td>
<div id='yes'></div>
</td><td><div id='text'></div>.....etc...</table></div>


When you call 'change', have it change all of the pertinent divs

have arrays for only text (qText, yText), another for onclicks -- don't dupe things. if two or more clicks require the same results -- good -- send them to the same array cell (because it is q[33] doesn't mean that it has to go to y[33].

This is much cleaner than the one you have, and note that it begins with '0', not '1'.

var keep=new Array();
for (var i = 0; i < 24; i++)
{
keep[i]='';
}

And I actually wouldn't even create the cells beforehand. I create them dynamically as needed. something like:

function add2Keep(question, value)
{
var len = keep.length;
keep[len++] = question;
keep[len] = value;
}


Vinny