2
I need to submit the data of a form (are Hidden) when selecting the option in select, this with ajax without page Reload.
I have the following code, which works well but does not send (POST) the form data that are Hidden:
<form class="form-horizontal" method="POST" action='#' name="dateForm">
<input type='hidden' name='cond_acao' class='form-control' value="edit_seccao_formando">
<input type="hidden" name="id_formando" value="<?=$linha_formandos[id_formando];?>">                             
<select name="id_seccoes" class="form-control" onchange="return postSelection">
    <option selected="selected" value="1">car</option>
    <option value="2">boat</option>
    <option value="3">plane</option>       
</select>
<div id='response_seccoes'></div>    
  <script>
    function postSelection(selectObject) {
        var id_seccoes = window.dateForm.id_seccoes.value = selectObject.options[selectObject.selectedIndex].value;
        var dataString = "id_seccoes=" + id_seccoes;
        $.ajax ({
        type:"post",
        url: "url.php",
        data:dataString,
        success: function (response) {
            $('#response_seccoes').html("ok").fadeIn(100).delay(2000).fadeOut("slow");
            //$("#list").html(response);
        }
      });
        return false;
    };
 </script> 
</form> 
It is possible to serialize instead of specifying strings?
where "form" is the name of the form (form name)? I tried to put how you told me by replacing : var id_seccoes = window.dateForm.id_seccoes.value = selectObject.options[selectObject.selectedIndex]. value; var dataString = "id_seccoes=" + id_seccoes; but
– Rui Banha
It is a Jquery selector, can call by tag, id, name etc. The serialize should work yes, check if the function is being called correctly. If not, try changing your select to: <select name="id_seccoes" class="form-control" onchange="postSelection(this);">
– Lucas Matias