Código Javascript:
Ver original
function AltaEmpresaOperari(){ var msg = confirm("Desea Agregar este Operario?") if ( msg ) { $.post("configuracions/empresa/nou_operari.php", { id_empresa: $('#id_empresa').attr('value'), nom: $('#newnom').attr('value'), cognom: $('#newcognom').attr('value'), preu_ac: $('#newpreu_ac').attr('value'), preu_av: $('#newpreu_av').attr('value'), beforeSend: function(){ if ($('#newnom').attr('value')==""){ alert("El Nombre del Operario es un dato Obligatorio."); $("#newnom").focus(); return false; } }, success: function(datos){ cadena = "<tr>"; cadena = cadena + "<td><input type='text' id='nom' name='nom' value='" + $("#newnom").val() + "'/><td>"; cadena = cadena + "<td><input type='text' id='cognom' name='cognom' value='" + $("#newcognom").val() + "'/><td>"; cadena = cadena + "<td><input type='text' id='preu_ac' name='preu_ac' value='" + $("#newpreu_ac").val() + "'/><td>"; cadena = cadena + "<td><input type='text' id='preu_av' name='preu_av' value='" + $("#newpreu_av").val() + "'/><td>"; cadena = cadena + "<td class='td_resultats' align='center' width='5%' title='Alta Reciente'><img src='../lib/img/generics/up.png'></td>"; cadena = cadena + "</tr>"; $("#empresa_operaris tbody").after(cadena); }, complete: function(){/*Quan s'hagi completat*/} }); } }
Código HTML:
<div id="operaris_empresa" style="display:none;"> <form id="frmOperaris" name="frmOperaris" method="post" action="javascript: AltaEmpresaOperari();"> <input type="hidden" id="id_empresa" name="id_empresa" value="<?php echo $_GET['id'];?>"/> <table class="taula_resultats"> <tr> <th class="th_resultats">Nombre</th> <th class="th_resultats">Apellido</th> <th class="th_resultats">Precio Preventivo</th> <th class="th_resultats">Precio Averia</th> <th rowspan="2"><input type="image" src="../lib/img/generics/ok.png" id="submit" name="submit" value="Guardar"></th> </tr> <tr> <td class="td_resultats" align="left"><input type="text" id="newnom" name="newnom" value=""/></td> <td class="td_resultats" align="left"><input type="text" id="newcognom" name="newcognom" value=""/></td> <td class="td_resultats" align="left"><input type="text" id="newpreu_ac" name="newpreu_ac" value=""/></td> <td class="td_resultats" align="left"><input type="text" id="newpreu_av" name="newpreu_av" value=""/></td> </tr> </table> </form> <div id="list_operaris" class="list_operaris"> <table id="empresa_operaris" class="taula_resultats"> <tr> <th class="th_resultats">Nombre</th> <th class="th_resultats">Apellido</th> <th class="th_resultats">Precio Preventivo</th> <th class="th_resultats">Precio Averia</th> <th> </th> </tr> <tbody> <?php if($sql_operaris) { while( $operaris = mysql_fetch_array($sql_operaris) ){ ?> <tr id="fila-<?php echo $operaris['id_operari'] ?>"> <td class="td_resultats" align="left" width="25%"><input type="text" id="nom" name="nom" value="<?php echo utf8_decode($operaris['nom']); ?>"/></td> <td class="td_resultats" align="left"><input type="text" id="cognom" name="cognom" value="<?php echo utf8_decode($operaris['cognom']); ?>"/></td> <td class="td_resultats" align="left"><input type="text" id="preu_ac" name="preu_ac" value="<?php echo $operaris['preu_ac']; ?>"/></td> <td class="td_resultats" align="left"><input type="text" id="preu_av" name="preu_av" value="<?php echo $operaris['preu_av']; ?>"/></td> <? if($operaris['situacio'] == 0){?> <td class="td_resultats" align="center" width="5%" title="Dar de Baja"><img src="http://www.forosdelweb.com/f127/lib/img/generics/up.png" onClick="AltaBaixaOperari('b',<?php echo $operaris['id_operari'] ?>); return false"></td> <?php }else{ ?> <td class="td_resultats" align="center" width="5%" title="Dar de Alta"><img src="http://www.forosdelweb.com/f127/lib/img/generics/down.png" onClick="AltaBaixaOperari('a',<?php echo $operaris['id_operari'] ?>); return false"></td> <?php }//if($operaris['situacio'] == 0){ ?> </tr> <?php } } ?> </tbody> </table> </div> </div>