Take data from Forms

Asked

Viewed 767 times

2

How can I get data from all the existing Rms on a page? I have a form with the name "orcamentos" that I can send the fields but I have at least three more that are inserted via include and the fields of these Forms I’m not being able to recover.

I would like to pass all fields, regardless of the name.

Before I was doing so:

document.orcamentos.submit();

This sends all form data with the name "budget", then in trying to send all fields independent of the name tried this:

$("form").submit();

But send the fields of the form "budget" and the others inserted by include no.

Performing some tests I realized that the variables that are not in the form "budget" are available and I was able to rescue them via Ajax, as follows:

            var sVazaoEta     = $("#Vazao_eta").val();
        var sTipoVazaoEta = $("input[name='TipoVazao_eta']:checked").val(); 
        var sFiltrosEta   = $("input[name='Filtros_eta']:checked").val();               

Is there any possibility of passing these variables to the detail page that is triggered by the form’s Submit, because I am using the:

$("form").submit(); 
  • How do you upload the form to the server side? via ajax? And why not load the new fields into the existing form without putting more Forms on the page?

  • The Forms that are inserted via include need to be filled by the user and are in the details of a shopping cart, for example by clicking "+ Customize Quote" I show this form that are entered by include according to the product category, the fields that are being sent correctly are the user data and are out of this cart. See this page for details: http://limpida.ind.br/orcamentos.php?add=532

  • Thanks @Kazzkig, interesting, but I need to fire "all" the Forms in a single button.

2 answers

3


You can use jQuery to serialize data from all forms and submit using jQuery’s $.get or $.post

In this link you will get information on how to serialize 1 (one) form In this link you will have information on how to serialize the form in the array format this is useful, as you can add new elements to the array, in your case the data from the other forms. You can serialize to an array the quotation form and add in this array the data of all other forms. In this link you will have information on how to turn objects into parameters to be sent by the get or post method, in case you need to add anything else manually. In this link you will get information on how to send data using the jQuery post In this link you will get information on how to send data using jQuery get

  • Thanks @Sileno Brito, I will give a study on the possibilities.

0

You can use the following javascript to send the data of two or more Forms:

<script language="javascript">
function() submitForms{
  document.getElementById("firstform").submit();
  document.getElementById("secondform").submit();
 }
</script>

<form id="firstform" target="iframe1">
</form><iframe name="iframe1" style="display:none"></iframe>
<form id="secondform" target="iframe2">
</form><iframe name="iframe1" style="display:none"></iframe>
<button onclick="submitForms()"><img src="images/order-button.png" "/></button>
  • An interesting solution @Gustavo Emmel, I will test this idea of yours, thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.