|
Posted by Erwin Moller on 05/19/06 15:47
Luke wrote:
> Hello guys! Thank you for your posts!
>
> Life is not so easy... forms include all possible HTML elements (text,
> radio, select, textarea, lists) so the parsing would have to be more
> sophisticated. I'll look at your examples.
>
> Keep in mind, that forms all already designed, so I can not output the
> entire forms/tables/html [like in one of your examples]! Forms always
> have to look the same (while filling out/editing/printing).
>
> Also, since it was all designed by drag and drop tools, HTML is
> horrible! single <input> element takes about 5 lines /tons of styles
> and javascript/
>
> Any other ideas folks?
>
> Luke
OMG...
Sounds you are stuck with a poorly designed solution.
(Me feels sorry for you.)
If I understand you right you want to insert all values in the form.
Also selected radio-options/checkboxes/etc.
How the form is builded is unknown.
The values are stored on some database.
Your goal is to show a forms with their values set?
Is this right?
What MIGHT help you is a approach like this:
(This assumes you are able to get a value for a question from the database
if you get the formname and the elementname)
1) Via JS you can loop over a form and retieve all elements AND their names.
2) Make code that branches for all possible formelementtypes.
3) Use AJAX to retrieve the value for that option by sending the name of the
form and the name of the formelement
4) Let the receiving script (The ajax-part on the surver) retieve the value
from the database and return it.
In case of multiple options you have to make up your own dataformat, with
comma's or something.
5) When the HTTPXMLOBJECT gets the answer, use it to set the right
options/values in the script.
I think such a solution might be easier than trying to parse an awefull
constructed HTML-page that contains the form.
If you are unfamiliar with AJAX, it is easy to learn.
A good startingpoint: http://www.w3schools.com/ajax
If your form contains 1000 elements, a straightforward approach would also
require 1000 requests to the server, possibly making this solution
extremely slow.
just my 2 cent.
Regards,
Erwin Moller
Navigation:
[Reply to this message]
|