elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Sigue las noticias más importantes de seguridad informática en el Twitter! de elhacker.NET


  Mostrar Mensajes
Páginas: 1 2 3 4 5 [6] 7 8 9 10 11 12 13 14 15 16
51  Programación / Desarrollo Web / Ayuda para retomar programación en: 9 Octubre 2016, 18:07 pm

Hola a todos,

Hace un tiempo empecé a programar y tuve un accidente y he estado sin tocar nada de programar bastante tiempo, tanto que no me acuerdo de casi nada

La cuestión que en lo que tenía programado, tenía el siguiente index.php

Sé que está fatal, la cuestión es que he intentado tocar el css asociado y lo he destrozado.

Os lo adjunto debajo. ¿Como podría simplificar el index y que la parte de registro de usuario me quedara minimamente user friendly? He tocado el css y lo he dejado peor, voy a empezar de cero pero por si alguien en un vistazo es capaz de darme algunos consejos y pautas.

Muchas Gracias.
 
Código
  1.  
  2. <!DOCTYPE html>
  3. <html lang="es">
  4.  
  5. <br>
  6.  
  7.  
  8.  
  9.  
  10. <TABLE WIDTH="100%" HEIGHT="100%">
  11.  
  12.  
  13. <TR>
  14.  
  15.  
  16. <TD VALIGN="MIDDLE" ALIGN="CENTER">
  17.  
  18.  
  19.  
  20.  
  21.  
  22. <FONT SIZE=6>  Research <FONT>
  23. <br>
  24.  
  25. <FONT SIZE=2> Quantitative Solutions <FONT>
  26.  
  27.  
  28.  
  29. </TD>
  30.  
  31.  
  32. </TR>
  33.  
  34. </TABLE>
  35.  
  36. <head>
  37.  
  38.  
  39. <title> Company
  40. </title>
  41.  
  42. <meta charset="utf-8"/>
  43. <meta name="description" content="Análisis  "/>
  44. <meta name="viewport" content="width=devide-width,initial-scale=1"/>
  45. <link rel="shortcut icon" type="image/x-icon" href="favicon.ico"/>
  46. <link rel="stylesheet"  href="css/estilos.css" />
  47.  
  48.  
  49. <!--[if lt IE 9]>
  50. <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  51. <![endif]>-->
  52.  
  53. <link rel="stylesheet" href="flexslider.css"  media="screen" />
  54. <script src="jquery.min.js"></script>
  55. <script src="jquery.flexslider-min.js"></script>
  56. <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
  57.  
  58. <!-- Includes for this demo -->
  59. <link rel="stylesheet" href="css/flexslider.css" media="screen" />
  60.  
  61. <!-- Hook up the FlexSlider -->
  62. <script>
  63. $(window).load(function() {
  64. $('.flexslider').flexslider();
  65. });
  66. </script>
  67.  
  68.  
  69.  
  70.    <script type="text/javascript">
  71.    <!--
  72.        $().ready(function() {
  73.            $("#frmlogin").validate();
  74.            $("#usuario").focus();
  75.        });
  76.    // -->
  77.    </script>
  78. </head>
  79.  
  80. <body>
  81.  
  82.  
  83. <header>
  84.  
  85.  
  86.  
  87.  
  88. <h1>
  89.  
  90. <a href="index.php" >
  91. <span class="f"></span>   <img  alt="bla bla" src="img/fondo-interno.jpg" width="50" height="50" />
  92. </a>
  93.  
  94.  
  95. </h1>
  96.  
  97.  
  98.  
  99.  
  100. <nav>
  101.  
  102. <ul>
  103. <li><a>Bienvenido, accede a tu cuenta</a></li>
  104.  
  105.  
  106.  
  107. </ul>
  108. </nav>
  109.  
  110.  
  111.        <nav>
  112.  
  113.        Prueba
  114.        </nav>
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123. </header>
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130. <section id="contenido">
  131. <section id="Mercados">
  132.  
  133.  
  134.  
  135.  
  136.    <article id="servicio3">
  137. <h3>Iniciar sesi&oacute;n  &nbsp;    </h3>
  138. <p>
  139.  
  140. <br /><br />
  141. <form id="frmlogin" name="frmlogin"  method="POST" action="validarUsuario.php">
  142. <table align="center" width="362" CELLPADDING="5">
  143.  
  144. <tr>
  145.    <td width="61">Usuario:</td>
  146.    <td width="142">
  147.        <input type="text" name="usuario" id="usuario" class="required" maxlength="50">
  148.    </td>
  149. </tr>
  150.  
  151. <tr>
  152.    <td>Password:</td>
  153.    <td>
  154.        <input type="password" name="password" id="password" class="required"  maxlength="50">
  155.    </td>
  156. </tr>
  157.  
  158.  
  159. <tr>
  160.    <td colspan="2" align="right">
  161.        <input type="submit" name="enviar" value="Enviar" >
  162.    </td>
  163.  
  164. </tr>
  165.  
  166.  
  167. </table>
  168. </form>
  169.  
  170.      </article>
  171.  </section>
  172. </section>
  173.  
  174.  
  175.  
  176.  
  177. <footer> Working progress</footer>
  178. </body>
  179. </html>
  180.  
  181.  
  182.  
  183.  


Código css

Código
  1.  
  2. /* Reglas para trabjar  */
  3.  
  4. * {
  5. border:0;
  6. margin: 0;
  7. padding: 0;
  8. }
  9.  
  10.  
  11. article,figcaption,figure,footer,header,hgroup,nav,section{
  12. display: block;
  13.  
  14. }
  15.  
  16. body  {
  17. background: #212121  url(../img/fondo.jpg);
  18. color:#FFF;
  19.  
  20.  
  21.  
  22. }
  23.  
  24.  
  25.  
  26. a{
  27.  
  28. color: #CEF6F5;
  29.  
  30. font-weight:bold;
  31. text-decoration:none;
  32.  
  33. }
  34.  
  35. a:hover{
  36.  
  37. color: #CEF6F5;
  38.  
  39. }
  40.  
  41.  
  42.  
  43. figcaption {
  44.  
  45. font-size: 0.85em;
  46. padding: 0.25em;
  47. text-align: center;
  48. min-height: 1500px;
  49. }
  50.  
  51. img, video{
  52. max-width: 100%;
  53.  
  54. }
  55.  
  56.  
  57.  
  58. header, section#contenido,section#contenido2, section#contenido111, footer {
  59.  
  60. background: #FFF url(../img/fondo-interno.jpg);
  61. margin: 0 auto;
  62. max-width: 100%;
  63. text-align: center;
  64.  
  65. }
  66.  
  67.  
  68. header h1, h2, h3, h4,h5,h6, nav {
  69.  
  70. display: inline-block;
  71. max-width: 100%;
  72. vertical-align: middle;
  73. }
  74.  
  75.  
  76.  
  77.  
  78.  
  79. h3,h4, h5{
  80. background: #E2E7F1;
  81. border-radius: 1em;
  82. margin-bottom: .5em;
  83. padding-left: .5em;
  84. box-shadow: .25em .25em .25em rgba(255, 153, 0,.5);
  85. color:#000000;
  86. }
  87.  
  88.  
  89.  
  90. h6{
  91. background: #E2E7F1;
  92. border-radius: 1em;
  93. margin-bottom: .5em;
  94. padding-left: .5em;
  95. box-shadow: .25em .25em .25em rgba(255, 153, 0,.5);
  96. color:#000000;
  97. }
  98.  
  99.  
  100. ol{
  101. padding: 0 2em;
  102. }
  103.  
  104. ol li{
  105. padding: 1em 0;
  106. }
  107.  
  108. nav ul{
  109.  
  110. list-style: none;
  111.  
  112. }
  113.  
  114.  
  115. nav li{
  116.  
  117. display: inline-block;
  118. padding=0.1em;
  119. vertical-align: top;
  120.  
  121.  
  122. }
  123.  
  124.  
  125.  
  126. nav a{
  127.  
  128. background: #FFF;
  129. border: 0.1em solid #57ABB8;
  130. border-radius: 0.25em;
  131. color: #F60;
  132. display: block;
  133.  
  134. font-size: 1.4em;
  135. padding: 0.2em;
  136. -ms-transition: all 0.5s ease-in;
  137. -moz-transition: all 0.5s ease-in;
  138. -o-transition: all 0.5s ease-in;
  139. -webkit-transition: all 0.5s ease-in;
  140. transition: all 0.5s ease-in;
  141.  
  142. }
  143.  
  144.  
  145. nav a:hover{
  146.  
  147. background: #212121;
  148. border: 0.1em dashed #F60;
  149. border-radius: 0 0.5em 0 0.5em;
  150. color: #FFF;
  151. -ms-transition: all 0.5s ease-out;
  152. -moz-transition: all 0.5s ease-out;
  153. -o-transition: all 0.5s ease-out;
  154. -webkit-transition: all 0.5s ease-out;
  155. transition: all 0.5s ease-out;
  156.  
  157.  
  158.  
  159. }
  160.  
  161.  
  162. section#principal, aside{
  163.  
  164. background: #1E6381;
  165.  
  166. border-radius: 0.5em;
  167.  
  168. display: inline-block;
  169.  
  170. margin: 0 auto;
  171. max-width: 100%;
  172. padding: 0.25em;
  173. vertical-align: top;
  174. width: 65%;
  175.  
  176. }
  177.  
  178.  
  179.  
  180. aside{
  181. width: 30%;
  182. }
  183.  
  184. aside img{
  185. border-radius: 0.5em;
  186. }
  187.  
  188.  
  189.  
  190.  
  191. section#Mercados{
  192.  
  193. margin: 0 auto;
  194. max-width:100%;
  195.  
  196. }
  197.  
  198.  
  199.  
  200.  
  201. article#servicio1, article#servicio3{
  202. background: #F6FCFC;
  203. margin-top: 4px; margin-right; 8px; margin-bottom: 8px; margin-left: 8px
  204. text-align: justify;
  205. border-radius: 0.5em;
  206. max-width:400 px;
  207. min-width: 400 px;
  208. min-height: 400 px;
  209. max-height: 400px;
  210.  
  211. padding: 0.995em;
  212. vertical-align: justify;
  213. color: #C00;
  214.  
  215.  
  216.  
  217. }
  218.  
  219. article#servicio99{
  220. background: #F6FCFC;
  221. margin-top: 4px; margin-right; 8px; margin-bottom: 8px; margin-left: 8px
  222. text-align: justify;
  223. border-radius: 0.5em;
  224.  
  225.  
  226. padding: 0.995em;
  227. vertical-align: center;
  228. width: 98%;
  229.  
  230. color: #C00;
  231.  
  232.  
  233.  
  234. }
  235.  
  236.  
  237. article#servicio1,article#servicio3{
  238. text-align: justify;
  239. background: #F6FCFC;
  240. border: 1px solid #d0d0d0;
  241. display:inline-block;
  242. border-radius: 0.5em;
  243. vertical-align: center;
  244. width: 31%;
  245. heigth: 21%;
  246. max-height: 10px;
  247. max-width: 200px;
  248. }
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256. footer{
  257.  
  258. color: #000;
  259. font-size: 0.85em;
  260. padding: 0.75em 0;
  261.  
  262. }
  263.  
  264.  
  265. .fade{
  266. opacity: 1;
  267. filter :alpha(opacity=10);
  268. -ms-transition: all 0.5s ease-in;
  269. -moz-transition: all 0.5s ease-in;
  270. -o-transition: all 0.5s ease-in;
  271. -webkit-transition: all 0.5s ease-in;
  272. transition: all 0.5s ease-in;
  273. }
  274.  
  275. .fade:hover{
  276. opacity: 0.7;
  277. filter :alpha(opacity=7);
  278. -ms-transition: all 0.5s ease-out;
  279. -moz-transition: all 0.5s ease-out;
  280. -o-transition: all 0.5s ease-out;
  281. -webkit-transition: all 0.5s ease-out;
  282.  
  283.  
  284. transition: all 0.5s ease-out;
  285.  
  286. }
  287.  
  288. @media(min-width:1081px){
  289. header h1{
  290. text-align: left;
  291. width:35%
  292. }
  293.  
  294. nav{
  295. text-align: center;
  296. width:100%
  297.  
  298. }
  299.  
  300. }
  301.  
  302. @media(max-width:1081px){
  303. nav li{
  304. font-size: 1.3em;
  305.  
  306. }
  307.  
  308. article#galeria-inicio{
  309.  
  310. width:80%
  311.  
  312. }
  313.  
  314. article#servicio1,article#servicio2,article#servicio3{
  315.  
  316. width:30%
  317. vertical-align: top
  318.  
  319.  
  320. }
  321.  
  322. aside{
  323. width: 20%;
  324.  
  325. }
  326.  
  327.  
  328. }
  329.  
  330. @media(max-width:800px){
  331. nav li{
  332. font-size: 0.95em;
  333.  
  334. }
  335.  
  336. article#galeria-inicio{
  337.  
  338. width:88%;
  339.  
  340. }
  341.  
  342. article#servicio1,article#servicio2,article#servicio3{
  343.  
  344. width:45%
  345.  
  346. }
  347.  
  348. }
  349.  
  350.  
  351.  
  352.  
  353. @media(max-width:600px){
  354.  
  355.  
  356. nav li{
  357. display: inline-block;
  358. margin: 0px;
  359. width:98%;
  360.  
  361.  
  362. }
  363.  
  364.  
  365. article#servicio1,article#servicio2,article#servicio3{
  366. width:50%
  367. }
  368.  
  369.  
  370. }
  371.  
  372. section#principal{
  373. margin-bottom: 0.2em;
  374. }
  375.  
  376. section#principal, aside{
  377. display: block;
  378.  
  379. width:95%
  380. }
  381.  
  382.  
  383. div.septrue {
  384. border-left:1px solid #363636;
  385. }
  386.  
  387. div.septrue {
  388. width:1px;
  389. height:17px;
  390. margin-top:7px;
  391. float:left;
  392. }
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
52  Programación / PHP / Re: PHP ON CLICK en: 20 Junio 2016, 16:29 pm
Sí a todo. Soy un desastre, lo único bueno a mi favor, es que entiendo por qué lo dices, lo entiendo de verdad y puedo corregirlo, solo que el tiempo aún no me lo ha permitido.

Muchas gracias lo veo y te digo, mil gracias otra vez.
53  Programación / PHP / Re: PHP ON CLICK en: 20 Junio 2016, 10:16 am
Mil gracias Gab, sí, eso lo veo, lo entiendo, pero ahora modificaciones no sé donde me equivoco a ver si puedes ver donde. Resulta que el archivo formulario1806.php ejecuta bien (veo que si en el formulario en el campo (el único que he definido) "cantidadkm" pongo 2 en el footer me muestra dos.

La cuestiójn es que ahora parece que la función onclick gracias() no está funcionando porque ya no me inserta nada en la base de datos ¿llamo mal las variables post para que me lean en gastos.php?

Estos son mis dos códigos:


formulario1806.php:


Código
  1.  
  2.  
  3. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  4.  
  5.  
  6. <?php
  7.  
  8.  
  9. //Inicializar una sesion de PHP
  10.  
  11. //Validar que el usuario este logueado y exista un UID
  12. if ( ! ($_SESSION['autenticado'] == 'SI' && isset($_SESSION['uid'])) )
  13. {
  14.    //En caso de que el usuario no este autenticado, crear un formulario y redireccionar a la
  15.    //pantalla de login, enviando un codigo de error        <form name="formulario" method="post" action="index.php">
  16. ?>
  17.        <form name="formulario" method="post" action="index.php">
  18.            <input type="hidden" name="msg_error" value="2">
  19.        </form>
  20.        <script type="text/javascript">
  21.            document.formulario.submit();
  22.        </script>
  23.  
  24. <?php
  25. }
  26.  
  27.    //Conectar BD
  28.    include("conectar_bd.php");  
  29.    conectar_bd();
  30.  
  31.    //Sacar datos del usuario que ha iniciado sesion"Propietario/a de ".$fila['Direccion']." ".$fila['PuertaLocalGaraje']
  32.    $sql = "SELECT   tx_nombre,tx_apellidoPaterno,tx_TipoUsuario,id_usuario, tx_password
  33.            FROM tbl_users
  34.            LEFT JOIN ctg_tiposusuario
  35.            ON tbl_users.id_TipoUsuario = ctg_tiposusuario.id_TipoUsuario
  36.            WHERE id_usuario = '".$_SESSION['uid']."'";        
  37.    $result     =mysql_query($sql);
  38.  
  39.    $nombreUsuario = "";
  40.  
  41. $cif = "";
  42.  
  43.  
  44.    //Formar el nombre completo del usuario
  45.    if( $fila = mysql_fetch_array($result) )
  46.        $nombreUsuario = "".$fila['tx_nombre'];
  47.        $cif = "".$fila['CIF'];
  48.  
  49.  
  50. //Cerrrar conexion a la BD  <form action="insertarvisitas.php" method="POST" name="form">echo '<td>'.'<a href="principal.php?id='.$muestra['ofi'].'">'.'<strong>Ir a Registrar</strong>'.'</a>'.'</td>';
  51. mysql_close($conexio);
  52.  
  53. ?>
  54.  
  55.  
  56. <html lang="es">
  57. <!doctype HTML>
  58. <head>
  59.  
  60.  
  61. <title> Prueba
  62. </title>
  63. <meta charset="utf-8"/>
  64.  
  65. <meta name="viewport" content="width=devide-width,initial-scale=1"/>
  66. <link rel="shortcut icon" type="image/x-icon" href="favicon.ico"/>
  67. <link rel="stylesheet"  href="css/estilos.css" />
  68.  
  69.  
  70. <!--[if lt IE 9]>
  71. <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  72. <![endif]>-->
  73.  
  74. <link rel="stylesheet" href="flexslider.css"  media="screen" />
  75. <script src="jquery.min.js"></script>
  76. <script src="jquery.flexslider-min.js"></script>
  77. <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
  78.  
  79. <!-- Includes for this demo -->
  80. <link rel="stylesheet" href="css/flexslider.css" media="screen" />
  81.  
  82. <!-- Hook up the FlexSlider -->
  83. <script>
  84. $(window).load(function() {
  85. $('.flexslider').flexslider();
  86. });
  87. </script>
  88.  
  89.  
  90.  
  91.    <script type="text/javascript">
  92.    <!--
  93.        $().ready(function() {
  94.            $("#frmlogin").validate();
  95.            $("#usuario").focus();
  96.        });
  97.    // -->
  98.    </script>
  99.  
  100.  
  101.  
  102. </head>
  103. <body>
  104. <header>
  105.  
  106. <!<Cerrrar conexion a la BDlink rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
  107. <!<Cerrrar conexion a la BDlink rel="icon" href="/favicon.ico" type="image/x-icon">
  108.  
  109. <h1>
  110. <a href="index.php" >
  111. <img class="fade" alt="bla bla" src="img/bextlan-logo.jpg" />
  112. </a>
  113.  
  114. </h1>
  115.  
  116.  
  117.  
  118.  
  119. <nav>
  120.  
  121.  
  122.  
  123. <h2>  <td  width="15px" align="center">
  124.        <!-- Proporcionar Link para cerrar sesion -->
  125.        <a href="cerrarSesion.php">Cerrar Sesi&oacute;n &nbsp;</a>
  126.    </td>
  127.  
  128. </h2>
  129.  
  130.  
  131.  
  132.  
  133.  
  134. </nav>
  135.  
  136.  
  137.  
  138.  
  139.  
  140. </header>
  141.  
  142.  
  143.  
  144. <section id="contenido2">
  145. <br/>
  146.  
  147.  
  148. <section id="Mercados2">
  149.  
  150.  
  151. <article id="servicio12">
  152.  
  153. <br/>
  154. <h3><tr>                                              <!-- Dar Bienvenida al usuario -->
  155.    <td  width="100px" align="right">Bienvenid@ <b><?php echo $nombreUsuario ?>&nbsp;&nbsp;</b></td>
  156.  
  157. </tr></h3>
  158. <p>
  159. <br/>
  160.  
  161.  
  162. Por favor, registra tu visita indicando todos los campos.
  163.  
  164. <br/>
  165. <br/>
  166.  
  167. <?php
  168.  
  169. ;
  170. ?>
  171.  
  172.  
  173.  
  174.        <script type="text/javascript" src="//code.jquery.com/jquery-2.2.4.min.js"></script>
  175.        <script type="text/javascript" src="js/scripts.js"></script>
  176.  
  177.        <script type="text/javascript">
  178.            $(function () {
  179.  
  180.                function fnAlltotal() {
  181.                        var alojamiento_total    = 0, dietas_total    = 0, otrosgastos_total    = 0,
  182.                            desplazamiento_total = 0;
  183.  
  184.                    $('.amount-aloj').each(function () {
  185.                        alojamiento_total += parseFloat($(this).val() || 0);
  186.                    });
  187.                    $('.amount-desp').each(function () {
  188.                        desplazamiento_total += parseFloat($(this).val() || 0);
  189.                    });
  190. $('.amount-dietas').each(function () {
  191.                        dietas_total += parseFloat($(this).val() || 0);
  192.                    });
  193.                    $('.alojamiento').val(alojamiento_total);
  194.                    $('.desplazamiento').val(desplazamiento_total);
  195. $('.dietas').val(dietas_total);
  196.                    $('.total').val((alojamiento_total + desplazamiento_total+ dietas_total).toFixed(2));
  197.  
  198.                }
  199.  
  200.                $('.unit').on('keyup', function () {
  201.                    var self = $(this),
  202.                        qtyVal = self.prev().val();
  203.  
  204.                    self.next().val(qtyVal * self.val());
  205.                    fnAlltotal();
  206.                });
  207.  
  208.                $('.qty').on('keyup', function () {
  209.                    var self = $(this),
  210.                        unitVal = self.next().val();
  211.  
  212.                    self.next().next().val(unitVal * self.val());
  213.                    fnAlltotal();
  214.                });
  215.  
  216.            });
  217.  
  218.  
  219.        </script>
  220. <script language="javascript" type="text/javascript">
  221.  function cambia(){
  222.  document.forms[0].elements[43].value='?me vas a pinchar?'
  223. }
  224.  
  225. function descambia(){
  226.  document.forms[0].elements[43].value='pinchame'
  227. }
  228.  
  229. function gracias(){
  230.  alert('!Gracias por pincharme!')
  231.   var parametros = { cantidadkm : "$_POST[cantidadkm]" };
  232.  
  233. $.post( "gastos.php", parametros  );
  234. };
  235.  </script>
  236.  
  237.  
  238.  
  239.  
  240.  
  241.    </head>
  242.  
  243.    <body>
  244.  
  245.  
  246.        <main>
  247.  
  248.            <div id="invoice">
  249.  
  250.                  <div class="alojamiento-box">
  251.                  <form name="formulario" method="post" action="formulario1806.php">
  252.                <h3>GASTOS REALIZADOS POR</h3>
  253.                <p>&nbsp;</p>
  254.  <h3>DESPLAZAMIENTO</h3>
  255.                <div class="alojamiento-box">
  256.                    <div>Km.:
  257.                        <input type="text" class="qty" name="cantidadkm" />
  258.                        Unit price:
  259.                        <input type="text" class="unit" value="0.19"  readonly/>Cantidad:
  260.                        <input type="text" class="amount-aloj" readonly />
  261.                  </div>
  262.                    <div>Km.:
  263.                        <input type="text" class="qty"  />
  264.                        Unit price:
  265.                        <input type="text" class="unit" value="0.19" readonly/>Cantidad:
  266.                        <input type="text" class="amount-aloj" readonly />
  267.                  </div>
  268.                  <div class="alojamiento-box">
  269.                    <div>Km.:
  270.                        <input type="text" class="qty"  />
  271.                        Unit price:
  272.                        <input type="text" class="unit" value="0.19" readonly/>Cantidad:
  273.                        <input type="text" class="amount-aloj" readonly />
  274.                  </div>
  275.                    <div>Transporte p&uacute;blico:
  276.                        <input type="text" class="qty"  />Gasto realizado:
  277.                        <input type="text" class="unit" />Cantidad:
  278.                        <input type="text" class="amount-aloj" readonly />
  279.                    </div>
  280.                    <div>Transporte Metropolitano:
  281.                        <input type="text" class="qty" />Gasto Realizado:
  282.                        <input type="text" class="unit" />Cantidad:
  283.                        <input type="text" class="amount-aloj" readonly />
  284.                    </div>Subtotal:
  285.                    <input type="text" class="alojamiento" readonly />
  286.              </div>
  287.  
  288.   <h3>DIETAS</h3>
  289.                <p>&nbsp;</p>
  290.  
  291.                <div class="alojamiento-box">
  292.                    <div>Km.:
  293.                        <input type="text" class="qty"  />
  294.                        Unit price:
  295.                        <input type="text" class="unit" value="0.19" readonly/>Cantidad:
  296.                        <input type="text" class="amount-dietas" readonly />
  297.                  </div>
  298.                    <div>Transporte p&uacute;blico:
  299.                        <input type="text" class="qty"  />Gasto realizado:
  300.                        <input type="text" class="unit" />Cantidad:
  301.                        <input type="text" class="amount-dietas" readonly />
  302.                    </div>
  303.                    <div>Transporte Metropolitano:
  304.                        <input type="text" class="qty" />Gasto Realizado:
  305.                        <input type="text" class="unit" />Cantidad:
  306.                        <input type="text" class="amount-dietas" readonly />
  307.                    </div>Subtotal:
  308.                    <input type="text" class="dietas" readonly />
  309.              </div>
  310.  
  311.              <br>
  312.              <br>
  313.  
  314. DIETAS
  315.  
  316.   <br>
  317.   <br>
  318.  
  319.                <div class="desplazamiento-box">
  320.                    <div>Quantity:
  321.                        <input type="text" class="qty" />Desayunos:
  322.                        <input type="text" class="unit /">Cantidad:
  323.                        <input type="text" class="amount-desp" readonly />
  324.                    </div>
  325.                    <div>Quantity:
  326.                        <input type="text" class="qty" />Gasto realizado:
  327.                        <input type="text" class="unit" />Cantidad:
  328.                        <input type="text" class="amount-desp" readonly />
  329.                    </div>
  330.                    <div>Cantidad:
  331.                        <input type="text" class="qty" />Gasto en Desayunos:
  332.                        <input type="text" class="unit /">Cantidad:
  333.                        <input type="text" class="amount-desp" readonly />
  334.                    </div>
  335.                    <div>Quantity:
  336.                        <input type="text" class="qty" />Gasto realizado:
  337.                        <input type="text" class="unit" />Cantidad:
  338.                        <input type="text" class="amount-desp" readonly />
  339.                         <div>Quantity:
  340.                        <input type="text" class="qty" />Gasto realizado:
  341.                        <input type="text" class="unit" />Cantidad:
  342.                        <input type="text" class="amount-desp" readonly />
  343.                    </div>Subtotal:
  344.                    <input type="text" class="desplazamiento" readonly />
  345.                </div><br />
  346.  
  347.  
  348.  
  349.   <br>
  350.   <br>
  351.  
  352.  
  353.  
  354.  
  355.  
  356.                Total: <input type="text" class="total" readonly />
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.          <center>
  373.  
  374. <input type="submit" name="boton"  value="pinchame" onMouseOver="cambia();" onMouseOut="descambia();" onClick="gracias();"></center>
  375.  
  376.       </div>
  377. </form>
  378.  
  379.        </main>
  380.  
  381.        <footer>
  382.      <?php echo $_POST[cantidadkm] ?>
  383.        </footer>
  384.  
  385.    </body>
  386.  
  387. </html>
  388.  
  389.  
  390.  


Y el de gastos.php


<?php

include("conexion.php");



if ( ! ( isset($_POST['cantidadkm'])) )
{


$host="localhost";
$db="ddddf";
$user="osftyh";
$pw="@dsdgg19d@";
$cantidadkm=$_POST['cantidadkm'];
$con=mysql_connect($host,$user,$pw) or die ("problemas al conectar");
mysql_select_db($db,$con) or die ("problemas al conectar la bd");

mysql_query("INSERT INTO `ugtdef`.`controlgastos` (`id_control`, `id_usuario`, `cantidadkm`) VALUES (NULL, '', `cantidadkm`='$cantidadkm')",$con);





}

 
?>


¿Por qué no me ejecuta gastos.php? ¿Y no me lee la variable cantidadkm?

Ay, gracias por adelantado.
54  Programación / PHP / Re: PHP ON CLICK en: 19 Junio 2016, 21:54 pm
Porfa,

Una ayuda. Jjejej. Os mendigo ayuda. Que no lo consigo.

Muchas Gracias por adelantado. Es que no sé como hacer el post para que cuando le de al botón que ejecuta gracias() que ejecuta gasto.php sepa leer cantidadkm y id_usuario.
55  Programación / PHP / Re: PHP ON CLICK en: 19 Junio 2016, 19:23 pm

Hola,

Dandole muchas vueltas he conseguido poniendo esto:
Código
  1.  
  2. function gracias(){
  3.  alert('!Gracias por pincharme!')
  4.  $.ajax({
  5.  
  6.   type: "POST",
  7.  url: "gastos.php",
  8.  
  9. });
  10.  
  11. }
  12.  

Que se ejecute gasto.php que sólo me insera el campo id_control (porque es null) y lo autoincrmenta phpmyadmin. La historia es que desde el archivo donde está la función gracias() no sé como hacer que viajen por post para que los lea "gastos.php" las variables:

id_usuario que debiera ser $_SESSION['uid'] y "cantidadkm" que debiera ser el valor introducido en el primer ítem del formulario que se llama así con name.

A ver si me podéis ayudar porfa.


La función gastos.php es esta:


Código
  1.  
  2. <?php
  3.  
  4. include("conexion.php");
  5.  
  6.  
  7.  
  8. if ( ! ($_SESSION['autenticado'] == 'SI' && isset($_SESSION['uid'])) )
  9. {
  10. $cantidadkm=$_POST[cantidadkm];
  11.  
  12. $host="localhost";
  13. $db="uytdeft";
  14. $user="ouser";
  15. $pw="@dudsdfsfeffs";
  16.  
  17. $con=mysql_connect($host,$user,$pw) or die ("problemas al conectar");
  18. mysql_select_db($db,$con) or die ("problemas al conectar la bd");
  19.  
  20. mysql_query("INSERT INTO `ugtdef`.`controlgastos` (`id_control`, `id_usuario`, `cantidadkm`) VALUES (NULL, '$_POST[id_usuario]', `cantidadkm`='$cantidadkm')",$con);
  21.  
  22.  
  23.  
  24.  
  25.  
  26. }
  27.  
  28.  
  29. ?>
  30.  
  31.  
  32.  
56  Programación / PHP / Re: PHP ON CLICK en: 18 Junio 2016, 22:57 pm
Hola Gab1 disculpa porque te enfadaste y con motivo, aunque sí que lo miré, no me aclaro, voy muy lento, y aprendo demasiado tarde. Te pido disculpas, a ver si me podeis ayudar tengo es código:

Código
  1.  
  2. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  3.  
  4.  
  5. <?php
  6.  
  7.  
  8. //Inicializar una sesion de PHP
  9.  
  10. //Validar que el usuario este logueado y exista un UID
  11. if ( ! ($_SESSION['autenticado'] == 'SI' && isset($_SESSION['uid'])) )
  12. {
  13.    //En caso de que el usuario no este autenticado, crear un formulario y redireccionar a la
  14.    //pantalla de login, enviando un codigo de error        <form name="formulario" method="post" action="index.php">
  15. ?>
  16.        <form name="formulario" method="post" action="index.php">
  17.            <input type="hidden" name="msg_error" value="2">
  18.        </form>
  19.        <script type="text/javascript">
  20.            document.formulario.submit();
  21.        </script>
  22.  
  23. <?php
  24. }
  25.  
  26.    //Conectar BD
  27.    include("conectar_bd.php");  
  28.    conectar_bd();
  29.  
  30.    //Sacar datos del usuario que ha iniciado sesion"Propietario/a de ".$fila['Direccion']." ".$fila['PuertaLocalGaraje']
  31.    $sql = "SELECT   tx_nombre,tx_apellidoPaterno,tx_TipoUsuario,id_usuario, tx_password
  32.            FROM tbl_users
  33.            LEFT JOIN ctg_tiposusuario
  34.            ON tbl_users.id_TipoUsuario = ctg_tiposusuario.id_TipoUsuario
  35.            WHERE id_usuario = '".$_SESSION['uid']."'";        
  36.    $result     =mysql_query($sql);
  37.  
  38.    $nombreUsuario = "";
  39.  
  40. $cif = "";
  41.  
  42.  
  43.    //Formar el nombre completo del usuario
  44.    if( $fila = mysql_fetch_array($result) )
  45.        $nombreUsuario = "".$fila['tx_nombre];
  46.  
  47.  
  48. //Cerrrar conexion a la BD  <form action="insertarvisitas.php" method="POST" name="form">echo '<td>'.'<a href="principal.php?id='.$muestra['ofi'].'">'.'<strong>Ir a Registrar</strong>'.'</a>'.'</td>';
  49. mysql_close($conexio);
  50.  
  51. ?>
  52.  
  53.  
  54. <html lang="es">
  55. <!doctype HTML>
  56. <head>
  57.  
  58.  
  59. <title>
  60. </title>
  61. <meta charset="utf-8"/>
  62.  
  63. <meta name="viewport" content="width=devide-width,initial-scale=1"/>
  64. <link rel="shortcut icon" type="image/x-icon" href="favicon.ico"/>
  65. <link rel="stylesheet"  href="css/estilos.css" />
  66.  
  67.  
  68. <!--[if lt IE 9]>
  69. <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  70. <![endif]>-->
  71.  
  72. <link rel="stylesheet" href="flexslider.css"  media="screen" />
  73. <script src="jquery.min.js"></script>
  74. <script src="jquery.flexslider-min.js"></script>
  75. <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
  76.  
  77. <!-- Includes for this demo -->
  78. <link rel="stylesheet" href="css/flexslider.css" media="screen" />
  79.  
  80. <!-- Hook up the FlexSlider -->
  81. <script>
  82. $(window).load(function() {
  83. $('.flexslider').flexslider();
  84. });
  85. </script>
  86.  
  87.  
  88.  
  89.    <script type="text/javascript">
  90.    <!--
  91.        $().ready(function() {
  92.            $("#frmlogin").validate();
  93.            $("#usuario").focus();
  94.        });
  95.    // -->
  96.    </script>
  97.  
  98.  
  99.  
  100. </head>
  101. <body>
  102. <header>
  103.  
  104. <!<Cerrrar conexion a la BDlink rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
  105. <!<Cerrrar conexion a la BDlink rel="icon" href="/favicon.ico" type="image/x-icon">
  106.  
  107. <h1>
  108. <a href="index.php" >
  109. <img class="fade" alt="bla bla" src="img/bextlan-logo.jpg" />
  110. </a>
  111.  
  112. </h1>
  113.  
  114.  
  115.  
  116.  
  117. <nav>
  118.  
  119.  
  120.  
  121. <h2>  <td  width="15px" align="center">
  122.        <!-- Proporcionar Link para cerrar sesion -->
  123.        <a href="cerrarSesion.php">Cerrar Sesi&oacute;n &nbsp;</a>
  124.    </td>
  125.  
  126. </h2>
  127.  
  128.  
  129.  
  130.  
  131.  
  132. </nav>
  133.  
  134.  
  135.  
  136.  
  137.  
  138. </header>
  139.  
  140.  
  141.  
  142. <section id="contenido2">
  143. <br/>
  144.  
  145.  
  146. <section id="Mercados2">
  147.  
  148.  
  149. <article id="servicio12">
  150.  
  151. <br/>
  152. <h3><tr>                                              <!-- Dar Bienvenida al usuario -->
  153.    <td  width="100px" align="right">Bienvenid@ <b><?php echo $nombreUsuario ?>&nbsp;&nbsp;</b></td>
  154.  
  155. </tr></h3>
  156. <p>
  157. <br/>
  158.  
  159.  
  160. Por favor, registra tu visita indicando todos los campos.
  161.  
  162. <br/>
  163. <br/>
  164.  
  165. <?php
  166.  
  167. ;
  168. ?>
  169.  
  170.  
  171.  
  172.        <script type="text/javascript" src="//code.jquery.com/jquery-2.2.4.min.js"></script>
  173.        <script type="text/javascript" src="js/scripts.js"></script>
  174.  
  175.        <script type="text/javascript">
  176.            $(function () {
  177.  
  178.                function fnAlltotal() {
  179.                        var alojamiento_total    = 0, dietas_total    = 0, otrosgastos_total    = 0,
  180.                            desplazamiento_total = 0;
  181.  
  182.                    $('.amount-aloj').each(function () {
  183.                        alojamiento_total += parseFloat($(this).val() || 0);
  184.                    });
  185.                    $('.amount-desp').each(function () {
  186.                        desplazamiento_total += parseFloat($(this).val() || 0);
  187.                    });
  188. $('.amount-dietas').each(function () {
  189.                        dietas_total += parseFloat($(this).val() || 0);
  190.                    });
  191.                    $('.alojamiento').val(alojamiento_total);
  192.                    $('.desplazamiento').val(desplazamiento_total);
  193. $('.dietas').val(dietas_total);
  194.                    $('.total').val((alojamiento_total + desplazamiento_total+ dietas_total).toFixed(2));
  195.  
  196.                }
  197.  
  198.                $('.unit').on('keyup', function () {
  199.                    var self = $(this),
  200.                        qtyVal = self.prev().val();
  201.  
  202.                    self.next().val(qtyVal * self.val());
  203.                    fnAlltotal();
  204.                });
  205.  
  206.                $('.qty').on('keyup', function () {
  207.                    var self = $(this),
  208.                        unitVal = self.next().val();
  209.  
  210.                    self.next().next().val(unitVal * self.val());
  211.                    fnAlltotal();
  212.                });
  213.  
  214.            });
  215.        </script>
  216. <script language="javascript" type="text/javascript">
  217.  function cambia(){
  218.  document.forms[1].elements[0].value='?me vas a pinchar?'
  219. }
  220.  
  221. function descambia(){
  222.  document.forms[1].elements[0].value='pinchame'
  223. }
  224.  
  225.  
  226.  
  227. function gracias(){
  228.  alert('!Gracias por pincharme!')
  229.  
  230.  
  231. }
  232.  </script>
  233.  
  234.  
  235.  
  236.  
  237.  
  238.    </head>
  239.  
  240.    <body>
  241.  
  242.  
  243.        <main>
  244.  
  245.            <div id="invoice">
  246.  
  247.                  <div class="alojamiento-box"> <form name="formulario" method="post" action="formulario1806.php">
  248.                <h3>GASTOS REALIZADOS POR</h3>
  249.                <p>&nbsp;</p>
  250.  <h3>DESPLAZAMIENTO</h3>
  251.                <div class="alojamiento-box">
  252.                    <div>Km.:
  253.                        <input type="text" class="qty" name="cantidadkm" />
  254.                        Unit price:
  255.                        <input type="text" class="unit" value="0.19"  readonly/>Cantidad:
  256.                        <input type="text" class="amount-aloj" readonly />
  257.                  </div>
  258.                    <div>Km.:
  259.                        <input type="text" class="qty"  />
  260.                        Unit price:
  261.                        <input type="text" class="unit" value="0.19" readonly/>Cantidad:
  262.                        <input type="text" class="amount-aloj" readonly />
  263.                  </div>
  264.                  <div class="alojamiento-box">
  265.                    <div>Km.:
  266.                        <input type="text" class="qty"  />
  267.                        Unit price:
  268.                        <input type="text" class="unit" value="0.19" readonly/>Cantidad:
  269.                        <input type="text" class="amount-aloj" readonly />
  270.                  </div>
  271.                    <div>Transporte p&uacute;blico:
  272.                        <input type="text" class="qty" value="1" />Gasto realizado:
  273.                        <input type="text" class="unit" />Cantidad:
  274.                        <input type="text" class="amount-aloj" readonly />
  275.                    </div>
  276.                    <div>Transporte Metropolitano:
  277.                        <input type="text" class="qty" />Gasto Realizado:
  278.                        <input type="text" class="unit" />Cantidad:
  279.                        <input type="text" class="amount-aloj" readonly />
  280.                    </div>Subtotal:
  281.                    <input type="text" class="alojamiento" readonly />
  282.              </div>
  283.  
  284.   <h3>DIETAS</h3>
  285.                <p>&nbsp;</p>
  286.  
  287.                <div class="alojamiento-box">
  288.                    <div>Km.:
  289.                        <input type="text" class="qty"  />
  290.                        Unit price:
  291.                        <input type="text" class="unit" value="0.19" readonly/>Cantidad:
  292.                        <input type="text" class="amount-dietas" readonly />
  293.                  </div>
  294.                    <div>Transporte p&uacute;blico:
  295.                        <input type="text" class="qty" value="1" />Gasto realizado:
  296.                        <input type="text" class="unit" />Cantidad:
  297.                        <input type="text" class="amount-dietas" readonly />
  298.                    </div>
  299.                    <div>Transporte Metropolitano:
  300.                        <input type="text" class="qty" />Gasto Realizado:
  301.                        <input type="text" class="unit" />Cantidad:
  302.                        <input type="text" class="amount-dietas" readonly />
  303.                    </div>Subtotal:
  304.                    <input type="text" class="dietas" readonly />
  305.              </div>
  306.  
  307.              <br>
  308.              <br>
  309.  
  310. DIETAS
  311.  
  312.   <br>
  313.   <br>
  314.  
  315.                <div class="desplazamiento-box">
  316.                    <div>Quantity:
  317.                        <input type="text" class="qty" />Desayunos:
  318.                        <input type="text" class="unit /">Cantidad:
  319.                        <input type="text" class="amount-desp" readonly />
  320.                    </div>
  321.                    <div>Quantity:
  322.                        <input type="text" class="qty" />Gasto realizado:
  323.                        <input type="text" class="unit" />Cantidad:
  324.                        <input type="text" class="amount-desp" readonly />
  325.                    </div>
  326.                    <div>Cantidad:
  327.                        <input type="text" class="qty" />Gasto en Desayunos:
  328.                        <input type="text" class="unit /">Cantidad:
  329.                        <input type="text" class="amount-desp" readonly />
  330.                    </div>
  331.                    <div>Quantity:
  332.                        <input type="text" class="qty" />Gasto realizado:
  333.                        <input type="text" class="unit" />Cantidad:
  334.                        <input type="text" class="amount-desp" readonly />
  335.                         <div>Quantity:
  336.                        <input type="text" class="qty" />Gasto realizado:
  337.                        <input type="text" class="unit" />Cantidad:
  338.                        <input type="text" class="amount-desp" readonly />
  339.                    </div>Subtotal:
  340.                    <input type="text" class="desplazamiento" readonly />
  341.                </div><br />
  342.  
  343.  
  344.  
  345.   <br>
  346.   <br>
  347.  
  348.  
  349.  
  350.  
  351.  
  352.                Total: <input type="text" class="total" readonly />
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.          </div>
  360.          </form>
  361.  
  362.          <center>
  363. <form name="form1">
  364. <input type="button" name="boton"  value="pinchame" onMouseOver="cambia();" onMouseOut="descambia();" onClick="gracias();"></center>
  365. </form>
  366.  
  367.        </main>
  368.  
  369.        <footer>
  370.  
  371.        </footer>
  372.  
  373.    </body>
  374.  
  375. </html>
  376.  
  377.  
  378.  

Este código no es para nada con ánimo de lucro, es para una asociación sin ánimo de lucro, intento aprender para ayudar a su vez. Por eso os pido ayuda.

La historia es que me gustaría enviar a una tabla "controlgastos" tres campos un id_registro con valor NULL, un usuario que sería $_SESSION['uid'] y name="cantidadkm" (luego ya añadiria otros campos con sus names)

En lo que leo de vuestros links la función gracias() del onclick debería "leer" cargar un archivo carga.php (que sería donde pondría el código mysqli)

Este paso cuando el usuario le da al botón es el que por mucho que leo, no veo como hacerlo.

Sé que me direis pobrecito, aun tiene animo, yo también me lo digo. Se que son preguntas chorras y las hago por desconocimiento. A ver si podéis ayudarme.

Muchas Gracias por adelantado.
57  Programación / PHP / PHP ON CLICK en: 13 Junio 2016, 08:20 am
Hola tengo un formulario, que me han ayudado en este foro, con js la cuestión es que el formulario me completa una serie de campos y me gustaría que al darle a un botón me guardara todos los campos en una tabla de mysql.

En algo similar leí que eso se haría con un "on click?" donde puedo leer sobre cómo funciona esa función. ¿Alguien podría ponerme un ejemplo chorra de como guardar datos dandole a un botón a una base de datos? Muchas Gracias.
58  Programación / PHP / Re: Formulario subtotales en: 7 Junio 2016, 09:48 am
Mil gracias.

Yo veo que funciona, pero cuando lo pongo todo en el php, un rueda?

Donde está lo que no veo? La idea es poner en el head el código js y luego llamar a la función en el body no?

Código
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Documento sin título</title>
  6.  
  7.  
  8. <script language="javascript" >
  9. function fnAlltotal() {
  10. var alojamiento_total = 0,
  11.       desplazamiento_total = 0;
  12.  
  13.    $(".amount-aloj").each(function(){
  14.         alojamiento_total += parseFloat($(this).val()||0);
  15.    });
  16.    $(".amount-desp").each(function(){
  17.         desplazamiento_total += parseFloat($(this).val()||0);
  18.    });
  19.    $(".alojamiento").val(alojamiento_total);
  20.    $(".desplazamiento").val(desplazamiento_total);
  21.   $('.total').val((alojamiento_total + desplazamiento_total).toFixed(2));
  22.  
  23. }
  24.  
  25. $(".unit").on('keyup', function () {
  26.    var self = $(this),
  27.     qtyVal = self.prev().val();
  28.  
  29.    self.next().val(qtyVal * self.val());
  30.  fnAlltotal();
  31. });
  32.  
  33. $(".qty").on('keyup', function () {
  34.    var self = $(this),
  35.        unitVal = self.next().val();
  36.    self.next().next().val(unitVal * self.val());
  37.   fnAlltotal();
  38. });
  39.  
  40. </script>
  41.  
  42. </head>
  43.  
  44. <body>
  45.  
  46. PAGOS
  47.  
  48.  
  49.  
  50. <br />
  51. <br />
  52.  
  53. <div class="alojamiento-box">
  54.    <div>Quantity:
  55.        <input type="text" class="qty" />Unit price:
  56.        <input type="text" class="unit" />Amount:
  57.        <input type='text' class='amount-aloj' readonly />
  58.    </div>
  59.    <div>Quantity:
  60.        <input type="text" class="qty" />Unit price:
  61.        <input type="text" class="unit" />Amount:
  62.        <input type='text' class='amount-aloj' readonly />
  63.    </div>
  64.    <div>Quantity:
  65.        <input type="text" class="qty" />Unit price:
  66.        <input type="text" class="unit" />Amount:
  67.        <input type='text' class='amount-aloj' readonly />
  68.    </div>Sub Total:
  69.    <input type="text" class="alojamiento" readonly />
  70. </div>
  71. <div class="desplazamiento-box">
  72.    <div>Quantity:
  73.        <input type="text" class="qty" />Unit price:
  74.        <input type="text" class="unit /">Amount:
  75.        <input type='text' class='amount-desp' readonly />
  76.    </div>
  77.    <div>Quantity:
  78.        <input type="text" class="qty" />Unit price:
  79.        <input type="text" class="unit" />Amount:
  80.        <input type='text' class='amount-desp' readonly />
  81.    </div>
  82.    <div>Quantity:
  83.        <input type="text" class="qty" />Unit price:
  84.        <input type="text" class="unit" />Amount:
  85.        <input type='text' class='amount-desp' readonly />
  86.    </div>Sub Total:
  87.    <input type="text" class="desplazamiento" readonly />
  88. </div><br />
  89. Total All: <input type="text" class="total" readonly />
  90.  
  91. <br>
  92. <br>
  93. <br>
  94.  
  95.  
  96. <script languaje="javascript">
  97. fnAlltotal();
  98. </script>
  99.  
  100.  
  101. </body>
  102. </html>
  103.  
  104.  


Esto no me rueda, calcula nada incluso poniendo, en el body:


Código
  1.  
  2. <?php
  3. <script languaje="javascript">
  4. fnAlltotal();
  5. </script>
  6. ?>
  7.  
  8.  

Siento la pregunta tonta, pero no consigo que "actue" el js
59  Programación / PHP / Re: Formulario subtotales en: 6 Junio 2016, 21:18 pm
Hola gAb1 lo primero mil gracias.

Estoy intentándo crear un archivo js y que lo lea pero nada...qué horror. Mira de aqui me saqué el código que estaba probando

http://jsfiddle.net/ch510dk3/2/

Se que es hacer trampas pero tú podrías ponerme un ejemplo de como haría rodar eso en un html o php¿?

A ver si me hechas un cable...

60  Programación / PHP / Formulario subtotales en: 6 Junio 2016, 08:25 am
Hola, quiero hacer un formulario de gastos, buceando por internet he visto algo que funciona:

Código
  1.  
  2. Quantity: Unit price: Amount:
  3.  
  4. Quantity: Unit price: Amount:
  5.  
  6. Quantity: Unit price: Amount:
  7.  
  8. Quantity: Unit price: Amount:
  9.  
  10. Quantity: Unit price: Amount:
  11.  
  12. Quantity: Unit price: Amount:
  13.  
  14. Total All:
  15.  
  16.  
  17.  

PREGUNTA 1

Se supone que para que multiplique y haga el total necesito este código de js, donde debo colocar esto para que calcule?:



Código
  1.  
  2.  
  3.  
  4. $(".qty").on('input', function () {
  5.    var self = $(this);
  6.    var unitVal = self.next().val();
  7.    self.next().next().val(unitVal * self.val());
  8.   fnAlltotal();
  9. });
  10.  
  11. $(".unit").on('input', function () {
  12.    var self = $(this);
  13.    var qtyVal = self.prev().val();
  14.    self.next().val(qtyVal * self.val());
  15.  fnAlltotal();
  16. });
  17.  
  18. function fnAlltotal(){
  19.  var total=0
  20.    $(".amount").each(function(){
  21.         total += parseFloat($(this).val()||0);
  22.    });
  23.    $(".result").val(total);
  24.  
  25. }
  26.  
  27.  
  28.  


PREGUNTA 2

Si utilizo dos subtotales en la página (utilizando el código anterior) pero dos veces (uno son gastos de alojamiento y otro bloque con su subtotal que sea gastos de desplazamiento) ¿Cómo conseguiría el total (suma de los dos subtotales?


PREGUNTA 3:

Si los campos de Quantity, total, etc quisiera que se guardaran en una tabla que quedara en la bdd mysql phpmyadmin (me explico fatal) ¿Cómo debería ponerlo en los campos? ¿Qué introducciones debería añadir?

Sé que son muchas cosas a ver si me podeis orientar
Páginas: 1 2 3 4 5 [6] 7 8 9 10 11 12 13 14 15 16
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines