Solved

Nested Form Tags and Javascript

Posted on 2006-07-05
5
844 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 500 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now