Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Referencing A Form Inside Of A Form

 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a very large form (Form A). I am trying to build a navigation system that would allow you to jump to sections in the form.

My little navigation system is form based (Form B) and the javascript function it calls can't seem to reference the Form B. But if I move Form B outside of Form A it works fine.

Here are some code samples. My plan was to duplicate Form B through out the lengthy Form A allowing users to jump around while they fill it out. Will this work? Is there another way to do this?

Here is the navigation form to be imbedded inside the large form.


Here is the javascript the form above submits too. The error I get is document.B is not an object. But it works fine if Form B is not inside of another form. I am guessing the way I reference the embedded form needs to change. But is there a way to do it?

 
Andrew Eccleston
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forms should not be nested within other forms. XHTML specifically forbids this. I can't seem to find details on nesting forms in the HTML 4.01 spec, but it's something you should avoid.
 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wonder if there is another way to do this?

Anyone have an ideas of how I could have users be able to jump from one area of the form to another to speed up the filling out of the form?

Thanks,

Luke
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You try anchors links or
this JavaScript

Eric
 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried anchors. For some reason the page doesn't "jump" to the correct location, although the url get modified accordingly (it is a JSP page, don't know if that has anything to do with it).

ie: www.page.com#link1 (but the page doesn't actually shift down to link1).

I will try playing with your script a bit. I want a table of contents that I can put through out the page. I should be able to call your script from a <a> tag using the onClick method. If I give another <a> an id on the page I think you script should be able to get the position if I pass in the id of the element I can to scroll too.

I will try this all out in a little bit.

Luke
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ie: www.page.com#link1 (but the page doesn't actually shift down to link1).


Perhaps you are not declaring the anchor correctly?
 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is little table of contents:



Here is the section 4 declaration:



Is this not correct?

Luke
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<a href="section4">Section 4</a><br>

Should be:

<a name="section4">Section 4</a><br>
 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That was it. Thanks for the help guys.

Luke
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic