Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8828195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:33:05+00:00 2026-06-14T07:33:05+00:00

I have two different forms on one page that dynamically generate inputs. One is

  • 0

I have two different forms on one page that dynamically generate inputs. One is used for text inputs and by pressing a button(I’ll call this form 1) another textbox appers. The other adds users to be notified. When a button is pressed a user is added to the list(I’ll call this form 2).

Say I have 3 text boxes generated on form 1, if I try to add another user with form 2 all of the textboxes from form 1 disappear because the data from form 1 isn’t being posted.

Here’s how the two forms are called

<form method="post">
<?
$friends = new common_functions();
$friends->add_friends($added_friends); //this is in common functions - also used for assistance invites
?>
<br>
</form>


<form method="post">
<br>
<?
$register = new common_functions(); 
$register->register_tasks($j, $reg_description, $reg_num);
?>
</form>
<?

When I change it so these are both posted at the same time (instead of individually as it currently is), the individual forms don’t work correctly.

To sum it up, is there any way to tell a form to post its data even when a submit button isn’t pressed? Something like onaction(post data from other form…)

This is from form 2. If I remove the method from this then I can’t properly delete items from the list.

if(count($added_friends) > 0){
        ?>
        <table width="200">
        <col width="150">
        <th>Name</th><th>Remove</th>
        <?
        $count = count($added_friends);
        for($i=0; $i< $count; $i++){
            if($added_friends[$i] == NULL){
                $count = $count;
            }
            $friend = $added_friends[$i];
            ?>

            <!-- allows a user to remove invited friends -->
            <form method="post">
            <tr><td><? echo $friend; ?></td><td><input type="submit" name="remove_friend" value="X"/>
            <input type="hidden" name="remove_name" value="<? echo $friend; ?>"/>
            <input type="hidden" name="added_friends" value="<? echo implode(',',$added_friends); ?>"/></td></tr>               </form>
            </form>
            <?
        }
        ?>
        </table>

    <?
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T07:33:06+00:00Added an answer on June 14, 2026 at 7:33 am

    I’m not certain of you’re exact needs, but for something like this I would use knockout.js. There are other such javascript frameworks like angularjs and backbone (google for more).

    Here is a simple knockoutjs example on jsFiddle displaying the functionality you’re looking for.

    Javascript

    var viewModel = function(){
        this.values = ko.observableArray();
        this.invited = ko.observableArray();
        this.addValue = function(){
            var txt = $('#form1 input').val();
            this.values.push(txt);
        }.bind(this);
        this.addInvite = function(){
            var txt = $('#form2 input').val();
            this.invited.push(txt);
        }.bind(this);
        this.sendData = function(){
            $.ajax({
                url: 'www.blah.com/blahblah',
                data: { text: this.values(), invited: this.invited() } 
            });   
        }.bind(this);
    }
    
    ko.applyBindings(new viewModel());
    

    HTML

    <head>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
        <script src="http://github.com/downloads/SteveSanderson/knockout/knockout-2.0.0.js"></script>
    </head>
    <body>
        <div id="form1">
            <input type="text" />
            <button data-bind="click: addValue">Add</button>
        </div>
        <div id="valueList" data-bind="visible: values().length > 0">
            <ul data-bind="foreach: values">
                <li data-bind="text: $data"></li>
            </ul>
        </div>
        <div id="form2">
            <input type="text" />
            <button data-bind="click: addInvite">Invite</button>
        </div>
        <div id="inviteList" data-bind="visible: invited().length > 0">
            <ul data-bind="foreach: invited">
                <li data-bind="text: $data"></li>
            </ul>
        </div>
        <button data-bind="click: sendData">Save</button>
    </body>
    

    As you can see knockoutjs relies on JQuery being available, but this also gives you access to JQuery’s ajax functionality. This allows you to send the data via ajax. I <3 knockoutjs for it’s simplicity and users love the magic it provides. You’ll have to modify the ajax options to suit your needs, of course

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two forms, and so two different submit buttons, for one page (page
I have a Django project that, on one page, has multiple forms (in different
I have Process objects that are monitored from two different views. A Windows.Forms.ListView (actually
I have two forms on one page: a results form and a search form.
I have a form with two different UserControls - one that contains a Telerik
I have a page (let's call it edit page) with two forms - the
I have a template page expecting two forms. If I just use one form,
Scenario I have a windows forms application. I want to use two different WCF
I have application in VB.net that have two different form (Form1 and Form2). Now
I would like to have a form that can submit to two different action

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.