?
Solved

Nested Form Tags and Javascript

Posted on 2006-07-05
5
Medium Priority
?
855 Views
Last Modified: 2008-02-01
Hi,

It appears nested forms do not work.. I have the following piece of code, which I had to simplify inorder to present my case.

<form name="aform" method="post" action="newfile.php">
      <input type="text" name="abc" value="somevalue">
      <input type="button" value="button" onclick="document.aform.submit();">

      <form name="bform" method="post" action="somefile.php">
      <input type="text" name="def" value="testvalue">
      <input type="button" value="button" onclick="document.bform.submit();">
      </form>
</form>


Can any body tell me why bform is not recognized by javascript and if there are any alterantives possible.. inorder to make this work..

Thanks
0
Comment
Question by:niftyhawk
  • 3
  • 2
5 Comments
 
LVL 36

Accepted Solution

by:
Zyloch earned 1000 total points
ID: 17046768
You cannot put a form inside a form. Since your form fields do not really coincide, why don't you just have the forms separate? If you need two submits, then do one with Javascript, and the other one will be normal.

Ted
0
 
LVL 1

Author Comment

by:niftyhawk
ID: 17046807
well, the real use of having nested forms is... the outer form has a table with rows having checkboxes and text boxes.. the user can manage checked items options by checking the check boxes and deleting them or modifying them. the inner form has multiple checkboxes and textboxes for each row of the outer form.
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 17046818
So it's just a structure thing? I'm afraid the only way you can get any structure is to maybe surround your form elements with an IDed <div> or make your name your forms a certain way.

Ted
0
 
LVL 1

Author Comment

by:niftyhawk
ID: 17046846
hmm..all my inner forms have a differentname and action..however, they have to be surrounded by an outer form, otherwise how would I know what variables have been passed during the form post?
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 17046850
I'm not too sure what you mean... What are you trying to do exactly, and what do you expect the structure of your $_POST array to be?

Ted
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question