aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Complex form creation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Complex form creation" Watch "Complex form creation" New topic
Author

Complex form creation

Nicholas Dean
Greenhorn

Joined: May 17, 2011
Posts: 23
Hi,

I was wondering if anyone could point me in the right direction.

I am intending on making a complex form. The form has may aspects that the user can add dynamically.

So we have a parent form, f1. Inside this we have a button called 'Add new block' - from here a new legend opens below with a table inside to which users can as many individual rows with new content as they wish.

This trend repeats as many times as the user would like.. So we can end up with a form, with two inner forms, each of those can have two more inner forms, and so on.

Using the <form> tag etc, doesn't really work well, by this I mean there is always an area that is a bit hacky. Using iframes can become confusing as there are times that the content needs to be defined, however we don't know what any of the content will look like nor contain.

I'm confused with an approach, one that will be user friendly and not require a masters to figure out the flow.

I have thought of making each individual inner form as a separate html page, where there is a blank table with loads of empty options, and the users fills these in accordingly. However this means that I have to have a potentially unlimited number of empty boxes residing on the page (as I do not know how many aspects the user will add).
It can be done this way, however it is a bit mechanical in its flow, and does not give the user complete freedom..

You may be aware that I am not a Web Developer at heart, I know some fundamentals, however I am being encouraged at the moment to output something grand, for proof of concept.

Thanks greatly for any hints or suggestions,
Nicholas Dean.
Mike Zal
Ranch Hand

Joined: May 04, 2011
Posts: 144

The problem seems like it would be a JavaScript solution and better suited for the HTML and JavaScript forum


OCJP6, OCWCD5
Nicholas Dean
Greenhorn

Joined: May 17, 2011
Posts: 23
Im new to this forum...is there someone, a moderator, that can move this thread or do I have to it myself?

Thanks,
ND.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61654
    
  67

Moved to the HTML forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61654
    
  67

You can't nest forms and you can't nest HTML pages. And I'm not sure why you were headed down that path anyways...

Simply add the new elements to the form. If there are repeating elements, the parameters will simply end up as an array on the server.

I think you are making this much more complicated than it needs to be.
Nicholas Dean
Greenhorn

Joined: May 17, 2011
Posts: 23
Exactly, how do you add these new elements?
I cannot seem to find a decent example of such a process.

Each of the inner 'forms' , for want of a better word at the moment, will be stored in a database as well (as a new table). Is this possible with javascript?
As you can see I'm not up-to-date with a lot of web development, and unfortunately my time scale is short. I do not want you guys to give me any answers etc, but a link to a decent tutorial on javascript html creation, etc would be greatly appreciated.

Thanks greatly,
ND.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61654
    
  67

Ah, so it's the JavaScript you are having issues with...

DOM manipulation is a rather advanced topic for a novice. You're best bet is to adopt one of the libraries like jQuery or Dojo that makes this process a lot easier. Even so, you've got a steep learning curve ahead of you.

If you are using Servlets and JSP on the back end, and are more familiar with those technologies, you might consider "cheating" and using Ajax (again, via jQuery) to simply fetch pre-formatted fragments to stick into the DOM rather than creating the element on-the-fly in script.
Nicholas Dean
Greenhorn

Joined: May 17, 2011
Posts: 23
See this aspect will be of a greater system. So the overall system willl be hosted on the cloud, so therefore I will be running servlets, and I have used some JSP throughout already.

So using Ajax/JQuery would be the method then? Do you have links to some decent examples or tutorials?

Thanks greatly,
ND.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Complex form creation