Hello,
I have a form and a grid, and must pass all form data to the server, but can not retrieve information from the grid with _POST method on the server side. I am using the function before the submit “parentFormOnSubmit” but does not work.
update_pagamentos.php I try to capture the identifiers of the grid with
“$ Ids = explode (”,",$_ POST ['ids “]);” but returns nothing.
Below is my code. Can anyone help me?
Thanks!
<?php
require "verifica_login.php";
$login = $_SESSION["NomUsu"];
$codusu = $_SESSION["CodUsu"];
header("Content-Type: text/html; charset=ISO-8859-1",true) ;
?><head>
<link rel="STYLESHEET" type="text/css" href="css/dhtmlxgrid.css">
<link rel="stylesheet" type="text/css" href="css/dhtmlxgrid_dhx_skyblue.css">
<link rel="STYLESHEET" type="text/css" href="css/dhtmlxcalendar.css">
<link rel="STYLESHEET" type="text/css" href="css/dhtmlxcalendar_simplegrey.css">
<script>window.dhx_globalImgPath="imagens/calendar/";</script>
<script src="script/dhtmlxcommon.js"></script>
<script src="script/dhtmlxgrid.js"></script>
<script src="script/dhtmlxgridcell.js"></script>
<script src="script/dhtmlxdataprocessor.js"></script>
<script src="script/dhtmlxgrid_form.js"></script>
<script src="script/dhtmlxform.js"></script>
<script src="script/dhtmlxcalendar.js"></script>
<script src="script/dhtmlxgrid_filter.js" type="text/javascript"></script>
<script type="text/javascript" src="script/prototype.js"></script>
<script type="text/javascript" src="script/src/scriptaculous.js"></script>
<title>Sistema de Controle de Receitas</title>
<link href="css/estilo.css" rel="stylesheet" type="text/css" />
</head>
<script type="text/javascript">
var cal1, newStyleSheet;
window.onload = function(){
function onCheckBox(id) {
var valor_total = 0;
document.getElementById("valsel").value = valor_total;
for (var i = 0; i < mygrid.getRowsNum(); i++) {
if (parseFloat(mygrid.cells2(i, 5).getValue()) == "1"){
valor_total += parseFloat(mygrid.cells2(i, 4).getValue());
document.getElementById("valsel").value = valor_total;
}
}
}
cal1 = new dhtmlxCalendarObject('DatPag');
cal1.setSkin("simplegrey");
dhtmlxCalendarLangModules['pt'] = {
langname: 'pt',
dateformat: '%d/%m/%Y',
monthesFNames: ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"],
monthesSNames: ["Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"],
daysFNames: ["Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sabado", "Domingo"],
daysSNames: ["Seg", "Ter", "Qua", "Qui", "Sex", "Sab", "Dom"],
weekend: [0, 6],
weekstart: 1
}
cal1.loadUserLanguage("pt");
var dhxForm = new dhtmlXForm("myform");
mygrid = new dhtmlXGridObject('gridbox');
mygrid.setImagePath("imagens/grid/");
mygrid.setHeader("Evento,Parcela,Vencimento,Valor a pagar, Valor pago,#master_checkbox,Observação");
mygrid.setInitWidths("130,60,100,90,90,40,*");
mygrid.setColAlign("left,center,center,center,center,center,left");
mygrid.setColTypes("ro,ro,ro,ro,price,ch,txt");
mygrid.setColSorting("str,str,na,int,int,str,str");
mygrid.attachEvent("onCheckBox", onCheckBox);
mygrid.setSkin("modern");
mygrid.submitOnlyChanged(false);
mygrid.init();
// myDataProcessor = new dataProcessor("update_pagamentos.php");
// myDataProcessor.setTransactionMode("POST", true);
// myDataProcessor.setUpdateMode("off");
// myDataProcessor.init(dhxForm);
Event.observe('observacao', 'keyup', obstodos, false);
function obstodos(){
for (var i = 0; i < mygrid.getRowsNum(); i++) {
mygrid.cells2(i, 6).setValue(document.getElementById("observacao").value);
}
}
new Ajax.Autocompleter('integrantes',
'integrantes_auto_completar',
'pagamentos_complete.php',
{
indicator:'opt'
})
}
function enviar(){
var integrante = document.getElementById('integrantes').value;
mygrid.loadXML("car_grid.php?integrante="+integrante);
}
function test(){
//alert("test");
mygrid.parentFormOnSubmit();
document.myform.submit();
}
</script>
<style>
div.auto_completar {
width: 350px;
background: #fff;
z-index:20;
}
div.auto_completar ul {
border:1px solid #888;
margin:0;
padding:0;
width:100%;
list-style-type:none;
}
div.auto_completar ul li {
margin:0;
padding:3px;
}
div.auto_completar ul li.selected {
background-color: #ffb;
}
body {
background-color: #999999;
}
#apDiv1 {
position:absolute;
left:15%;
top:auto;
width:900px;
height: 600px;
z-index:1;
background-color: #CCCCCC;
visibility: visible;
}
#ValTot {
position:absolute;
left:555px;
top:292px;
width:196px;
height:22px;
z-index:2;
visibility: visible;
}
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
}
.style4 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 16px;
font-weight: bold;
}
.style5 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
font-size: 12px;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /></head>
<form id="myform" name="myform" method="POST" action="update_pagamentos.php">
<div id="apDiv1">
<table width="869" border="0">
<tr>
<td height="108"> </td>
<td colspan="3"><div align="center">
<p><img src="imagens/pagamento2.png" width="100" height="100" />
<span class="style4">Pagamentos</span></p>
</div></td>
</tr>
<tr>
<td width="55" rowspan="7"> </td>
<td width="143" rowspan="2" valign="top">
<p align="left"><span class="style1">Integrante: </span>
</td>
<td height="24" colspan="2"><p>
<input autocomplete="off" id="integrantes" name="integrante" size="30" type="text" value="" />
<span id="opt" style="display:none;right:1%;color:#FFF;background-color:#FF0000;position:absolute;top:1px;">Carregando...</span></td>
</tr>
<tr>
<td colspan="2"> <div class="auto_completar" id="integrantes_auto_completar" LIMPAR A GRID ANTES DE RECARREGA-LA onclick="javascript:enviar()"></div></td>
</tr>
<tr>
<td width="143" height="28" valign="top"><span class="style1">Data do Pagamento: </span></td>
<td colspan="2" valign="top"><input type="text" id="DatPag" style="width: 80px; font-size:12px;" />
</td>
</tr>
<tr>
<td width="143" height="30" valign="top"><span class="style1">Tipo do Pagamento:</span></td>
<td colspan="2" valign="top"><select name="tippag" id="tippag">
<option value="1" selected="selected">Dinheiro</option>
<option value="2">Depósito</option>
<option value="3">Crédito</option>
</select></td>
</tr>
<tr>
<td width="143" height="30" valign="top"><span class="style1">Valor Entregue:</span></td>
<td colspan="2" valign="top"><input autocomplete="off" id="integrantes4" name="integrantes3" size="8" type="text" value="" />
</td>
</tr>
<tr>
<td width="143" height="29" valign="top"><span class="style1">Observação:</span></td>
<td width="338" valign="top"><input name="observacao" type="text" id="observacao" value="" size="50" maxlength="40" autocomplete="off" />
</td>
<td width="315" valign="top"><span class="style5">Valor Selecionado:
<input name="valsel" type="text" id="valsel" size="15" readonly="on"/>
</span></td>
</tr>
<tr>
<td colspan="3"><div id="gridbox" style="width:97%;height:188px;background-color:white;">
<p align="left"> </p>
</div>
<input type="button" name="some_name" value="update" onclick="javascript:test();" /></td>
</tr>
</table>
<div id="resultado"></div>
</div>
</form>
</body>
</html>