Buenas noches.
Tengo el problema al llamar una función javascript.
Yo hago un if preguntando si el botón salve fue seleccionado en php y guardo los datos, y luego llamo la función datos() hecha en javascript.
pero no me llama la función datos. Me podrían ayudar. Gracias.
Les dejo el código que utilizo.
Código HTML:
<?PHP
require 'conexions.php';
require 'funciones.php';
$conexion=Conectarse(); //select numpro, numcot from PROYECTO where numpro = $_GET[numpro]
$cargo=mysql_query("SELECT numcargo,nomcargo FROM cargo;",$conexion);
if($save){
$sql="insert into com_prov ( nit,nom_prov,id_estado) values('".$nom."','".$nom."','15')";
//echo $sql;
mysql_query($sql,$conexion);
$sql="insert into com_conctato (nit_prov,cargo,nomcont,tel) values('".$nom."','".$cargos."','".$contacto."','".$tel."')";
//echo $sql;
mysql_query($sql,$conexion);
echo "<script> datos();</script>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
<script>
function datos(){
var valor=document.form1.nom.value;
opener.document.form_soli.idprove.value=valor;
opener.document.form_soli.prov.add(new Option(valor, valor), null);
window.close();
}
</script>
<style type="text/css">
<!--
.Estilo1 {
color: #FFFFFF;
font-weight: bold;
}
-->
</style>
</head>
<body onload="window.focus()">
<form id="form1" name="form1" method="post" action="" enctype="multipart/form-data">
<table width="307" border="0" align="center" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="21" height="34" ><img name="plantilla_r1_c1" src="img/plantilla_r1_c1.gif" width="21" height="34" border="0" alt=""></td>
<td width="1012" valign="top" background="img/plantilla_r1_c20.gif"><!--DWLayoutEmptyCell--> </td>
<td width="24" ><img name="plantilla_r1_c3" src="img/plantilla_r1_c3.gif" width="24" height="34" border="0" alt=""></td>
</tr>
<tr>
<td background="img/plantilla_r2_c1.gif"> </td>
<td valign="top">
<table width="552" border="0" align="center" bordercolor="#F0F0F0" bgcolor="#E0E5EE">
<tr bgcolor="#666666">
<td colspan="2" bgcolor="#5E7694"><div align="center" class="Estilo1">DATOS DEL PROVEEDOR </div></td>
</tr>
<?php /*?> <tr>
<td width="224">IDENTIFICACION</td>
<td width="277"><!--<input type="text" name="textfield2" />-->
<input name="idprove" id="idprove" type="text" size="25" /></td>
</tr><?php */?>
<tr>
<td>NOMBRE O RAZON SOCIAL </td>
<td><!--<input type="text" name="textfield3" />-->
<input name="nom" type="text" id="nom" value="<?php echo $nom;?>" size="45" /></td>
</tr>
<tr>
<td>CONCTATO</td>
<td><input name="contacto" id="contacto" type="text" size="45"/></td>
</tr>
<tr>
<td>TELEFONO</td>
<td><input name="tel" id="tel" type="text" size="25" /></td>
</tr>
<tr>
<td>CARGO</td>
<td><select name="cargos" id="cargos">
<option value=""><Seleccione uno></option>
<?php
while ($fila=mysql_fetch_array($cargo)){
echo"<option value='".$fila["numcargo"] ."'>".$fila["nomcargo"]."</option>";
}
//
?>
</select></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="save" id="save" value="Enviar"/>
</div></td>
</tr>
</table>
<td background="img/plantilla_r2_c3.gif"></td>
</tr>
<tr>
<td height="23" ><img name="plantilla_r3_c1" src="img/plantilla_r3_c1.gif" width="21" height="23" border="0" alt=""></td>
<td valign="top" background="img/plantilla_r3_c2.gif" ><!--DWLayoutEmptyCell--> </td>
<td ><img name="plantilla_r3_c3" src="img/plantilla_r3_c3.gif" width="24" height="23" border="0" alt=""></td>
</tr>
</table>
</form>
<p></p>
</body>
</html>