<!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=utf-8" />
<?php
include "../config.php";
// connect to the mysql server
$link = mysql_connect($server, $db_user, $db_pass)
or die ("Could not connect to mysql because ".mysql_error());
// select the database
mysql_select_db($database)
or die ("Could not select database because ".mysql_error());
$qry = mysql_db_query($database, "select sublinea_articulo,descripcion from sublinea_articulos where ind_activo = 'S'") or die (mysql_error());
while ($result = mysql_fetch_array($qry)) {
$text = $text."<option value='".$result['sublinea_articulo']."'>".$result['descripcion']."</option>";
}
$option = array($text);
$qry1 = mysql_db_query($database, "select precio from sublinea_articulos where sublinea_articulo = 101") or die (mysql_error());
$result1 = mysql_fetch_array($qry1);
$tot_precio = $result1['precio'];
?>
<script type="text/javascript">
var idcot = 1;
function suma() {
var sublinea = "sublinea_"+idcot;
var codigo = "codigo_"+idcot;
var precio = "precio_"+idcot;
var talla = "talla_"+idcot;
var id_borrar = "BORRAR_"+idcot;
var miTabla = document.getElementById("cuerpoTabla");
var fila = document.createElement("tr");
fila.id = "rowDetalle_" + idcot;
var celda1 = document.createElement("td");
var celda2 = document.createElement("td");
var celda3 = document.createElement("td");
var celda4 = document.createElement("td");
var celda5 = document.createElement("td");
var opcion = [];
var tot_precio=0;
<?php
for($i=0; $i < count($option); $i++ ){
echo 'opcion['.$i.'] = "'.$option[$i].'";';
}
echo 'tot_precio = "'.$tot_precio.'";';
?>
celda1.innerHTML = '<select name="'+sublinea+'" id="'+sublinea+'" onchange="asigna_valor('+idcot+')">' + opcion + '</select>';
celda2.innerHTML = '<input type=text name="'+codigo+'" id="'+codigo+'" size="30">';
celda3.innerHTML = '<input type=text name="'+precio+'" id="'+precio+'" size="7" value="'+tot_precio+'">';
celda4.innerHTML = '<input type=text name="'+talla+'" id="'+talla+'" size="5">';
celda5.innerHTML = '<center><img src="../image/delete.png" width="16" height="16" alt="Eliminar" onclick="if(confirm(\'Realmente desea eliminar este artículo?\')){eliminarFila(' + idcot + ');}"/></center>';
fila.appendChild(celda1);
fila.appendChild(celda2);
fila.appendChild(celda3);
fila.appendChild(celda4);
fila.appendChild(celda5);
miTabla.appendChild(fila);
document.form1.cantidad.value=idcot;
idcot = idcot + 1;
}
function eliminarFila(idcot1){
var objHijo = document.getElementById('rowDetalle_' + idcot1);
var objPadre = objHijo.parentNode;
objPadre.removeChild(objHijo);
var cantidad1 = document.form1.cantidad.value-=1;
var cantidad_ant = cantidad1 + 1;
idcot1 = idcot1 + 1;
var a;
while (document.getElementById('rowDetalle_' + idcot1)) {
var idnew = idcot1-1;
var objnew = document.getElementById('rowDetalle_' + idcot1);
var sublinea = document.getElementById('sublinea_' + idcot1);
var codigo = document.getElementById('codigo_' + idcot1);
var precio = document.getElementById('precio_' + idcot1);
var talla = document.getElementById('talla_' + idcot1);
objnew.id = 'rowDetalle_' + idnew;
sublinea.setAttribute('name','sublinea_'+idnew);
codigo.setAttribute('name','codigo_'+idnew);
precio.setAttribute('name','precio_'+idnew);
talla.setAttribute('name','talla_'+idnew);
sublinea.setAttribute("id","sublinea_"+idnew);
codigo.setAttribute("id","codigo_"+idnew);
precio.setAttribute("id","precio_"+idnew);
talla.setAttribute("id","talla_"+idnew);
idcot1 = idcot1 + 1;
idcot = idnew+1;
}
//return false;
}
function asigna_valor(id) {
var id_sublinea = document.getElementById('sublinea_'+id).value;
var new_precio;
if(window.XMLHttpRequest) {
peticion_http = new XMLHttpRequest();
}
else if(window.ActiveXObject) {
peticion_http = new ActiveXObject("Microsoft.XMLHTTP");
}
peticion_http.open("GET", "change_precio.php?id_linea="+id_sublinea, true);
peticion_http.onreadystatechange=function(){
if(peticion_http.readyState == 4 && peticion_http.status ==200){
new_precio = peticion_http.responseText;
}
}
peticion_http.send(null);
var id_precio = document.getElementById('precio_' + id);
id_precio.setAttribute("value",new_precio);
}
</script>;
<title>Untitled Document</title>
<style type="text/css">
body {
background-image: url(../image/background.png);
}
h1,h2,h3,h4,h5,h6 {
font-family: "Agency FB";
}
h1 {
font-size: 12px;
color: #333;
font-family: Verdana, Geneva, sans-serif;
}
h2 {
font-size: 24px;
color: #333;
}
h3 {
font-size: 16px;
color: #C00;
}
#caja {
background-color: #FFFFFF;
height: 700px;
width: 810px;
padding: 10px;
/*para Firefox*/
-moz-border-radius: 20px 20px 20px 20px;
/*para Safari y Chrome*/
-webkit-border-radius: 20px 20px 20px 20px;
/* para Opera */
border-radius: 20px 20px 20px 20px;
}
#form1 #caja table tr td {
font-family: Verdana, Geneva, sans-serif;
color: #333;
font-weight: bold;
font-size: 9px;
}
strong {
color: #AB81D6;
}
#form1 #caja table tr td div p {
font-weight: normal;
}
#cuerpoTabla
{ background-color: white;
}
</style>
</head>
<body>
<div align="center">
<p><img src="../image/Movie1-000001.png" width="546" height="272" /></p>
<form id="form1" name="form1" method="post" action="register.php" onSubmit="return validate()">
<div id="caja">
<table width="776" height="193" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="9" colspan="2" bgcolor="#CCCCCC"> </td>
<td height="9" colspan="3" align="right" bgcolor="#CCCCCC"><h1>Bienvenido:</h1></td>
</tr>
<tr>
<td height="9" colspan="5" bgcolor="#CCCCCC" align="center"><h1>CONSULTA PEDIDOS | CREAR PEDIDO | PERFIL | SALIR</h1></td>
</tr>
<tr>
<td height="3" colspan="5" bgcolor="#999999"></td>
</tr>
<tr>
<td height="54" colspan="5"><h1><strong>CREACION DE PEDIDO</strong></h1></td>
</tr>
<tr align="center" bordercolor="#000000">
<td width="92"><h1> </h1></td>
<td height="27" colspan="3"><h1> </h1></td>
<td width="125"> </td>
</tr>
<tr>
<td> </td>
<td colspan="3"> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="3"> </td>
<td> </td>
</tr>
</table>
<table border="0">
<tr>
<td><input name="cantidad" type="text" size="1" maxlength="2" disabled="disabled"/></td>
<td><input type="button" name="Agregar" value="Agregar" onclick="suma()" /></td>
<td> </td>
<td><input type="submit" name="cnslt_total" value="Consulta final" /></td>
</tr>
<tr>
<td><tr></td>
</tr>
<table width="200xp" border="0" id="tblDetalle">
<thead>
<tr bgcolor="d9d9d9">
<th><font size='-1'><b>Artículos</b></th>
<th><font size='-1'><b>Código</b></th>
<th><font size='-1'><b>Precio</b></th>
<th><font size='-1'><b>Talla</b></th>
</tr>
</thead>
<tr></tr>
<tbody id="cuerpoTabla">
</tbody>
<tr>
<td></tr></td>
</tr>
</table>
<tr>
<td></tr></td>
</tr>
</table>
</div>
</form>
<p> </p>
</div>
</body>
</html>