Solved

Nested Form Tags and Javascript

Posted on 2006-07-05
5
852 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
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…

707 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