Weird question, can a button on a page "submit" a form from another page?

I have a index page that’s basically the parent page, I have an iframe that targets and opens other pages (in the iframe) when I click on the next button. The next button works like a submit button but also opens the next form page in the iframe.

Can I use the next button to submit data when the button isn’t on the form page?

Hope this makes sense…:joy:

Button code:

    <form action="start.html" target="preview-iframe" method="post">
        <button type="submit" form="truckForm" id="truckbtn" style='display:block' class="next action-button">Next</button>
    </form>

button js:

$(document).ready(function() {
       $("#truckbtn").click(function() {
           $("#truckForm").submit();
       });
    });

Form HTML:

<form id="truckForm" action="" method="post">
            <h2>Please Choose Truck:</h2>
            <div id="trucks" class="container">
                <div class="title">
                    <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                        <div class="panel panel-default">
                            <div class="panel-heading" role="tab" id="headingOne">
                                <h4 class="panel-title">

        <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="false" aria-controls="collapseOne">
          700kg Trucks
        </a>
      </h4> </div>
                            <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
                                <div class="panel-body">
                                    <div class="row">
                                        <div class="col-md-4"> <img class="img-responsive img-hover" img src="images/1.jpg" alt="2t"> </div>
                                        <div class="col-md-6">
                                            <h3>Caddy</h3>
                                            <form>
                                                <input type="checkbox" id="checkbox" name="Caddyselect" value="select"> </form>
                                            <div class="qty">
                                                <input type="button" onclick="decrementValue(this)" value="-" id="minus" />
                                                <input type="text" name="quantity1" value="0" maxlength="2" max="10" size="0" id="number" />
                                                <input type="button" onclick="incrementValue(this)" value="+" id="plus" /> </div>
                                            <!-- Trigger the modal with a button -->
                                            <button type="button" class="btn btn-info btn-small" data-toggle="modal" data-target="#myModal1"> Info</button>
                                            <!-- Modal -->
                                            <div class="modal fade" id="myModal1" role="dialog">
                                                <div class="modal-dialog modal-sm">
                                                    <div class="modal-content">
                                                        <div class="modal-header">
                                                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                                                            <h4 class="modal-title">Information</h4> </div>
                                                        <div class="modal-body">
                                                            <p>700kg closed Caddy.</p>
                                                        </div>
                                                        <div class="modal-footer"> </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

As far as I know, the value of the submit button is an element of the _$POST global array that is populated when the submit button is clicked on. And all the other elements of this $_POST array must be within the same form whose method is called with “POST” as the submit button.

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.