Jump to content

lingo5

Members
  • Posts

    426
  • Joined

  • Last visited

Everything posted by lingo5

  1. Xaotique, how can I display an initial value of zero for the result? // Show total div.find(".result").html(total); });
  2. Thanks !!!!!....it work now. http://www.redbook.es/facturator/test2.php I'm gonna play with this a bit more cause I want to make it look pretty and want to add more calculations to it... please don't go far !!!!...
  3. sorry Xaotique....my remove button still not working.... http://www.redbook.es/facturator/test2.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> <script type="text/javascript" src="../js/calculator2.js"></script> </head> <body> <input type="button" id="add" value="Add Row" /> <div id="container" style="margin-top: 5px;"></div> </body> </html> // Let page load $(document).ready(function() { // Add new row when button is clicked $("#add").click(function() { // Create the div (new row) and add its elements var div = $(document.createElement("div")).html('<table width="901" align="center"><tr class="prototype"><form name="form" ><td bgcolor="#F8F8F8"<input type="ee" class="id" value="<?php echo $referencia?>" size="10" /></td><td bgcolor="#F8F8F8"><input type="text" id="descripcion[]" size="40" /></td><td bgcolor="#F8F8F8"><input type="text" class="num" style="width: 100px;"/></td><td nowrap bgcolor="#F8F8F8"><input type="text" class="num" style="width: 100px;"/><span class="blackTXT">€</span></td><td bgcolor="#F8F8F8"><span class="blackTXT">21%</span><td nowrap bgcolor="#F8F8F8"><span id="result"></span> <span class="blackTXT"><span class="result"></span> €</span><td bgcolor="#F8F8F8"><input type="button" class="remove" value="Remove" /> </form></tr></table> '); // Add div to the page $("#container").append(div); // When we type into text area div.find(".num").keyup(function() { // Starting total var total = 1; // Cycle the values and multiply the parsed number div.find(".num").each(function(i, elmn) { total *= Number(elmn.value); }); // Show total div.find(".result").html(total); }); // Trigger keyup when value changes (right-click paste wouldn't be typing) div.find(".num").change($(this).keyup()); }); // Remove button functionality $(".remove").click(function() { $(this).parent().parent().remove(); }); });
  4. hi again, this is my html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> <script type="text/javascript" src="../js/calculator2.js"></script> </head> <body> <input type="button" id="add" value="Add Row" /> <div id="container" style="margin-top: 5px;"></div> </body> </html> and this is my js // Let page load $(document).ready(function() { // Add new row when button is clicked $("#add").click(function() { // Create the div (new row) and add its elements var div = $(document.createElement("div")).html('<table width="901" align="center"><tr class="prototype"><form name="form" ><td bgcolor="#F8F8F8"<input type="ee" class="id" value="<?php echo $referencia?>" size="10" /></td><td bgcolor="#F8F8F8"><input type="text" id="descripcion[]" size="40" /></td><td bgcolor="#F8F8F8"><input type="text" class="num" style="width: 100px;"/></td><td nowrap bgcolor="#F8F8F8"><input type="text" class="num" style="width: 100px;"/><span class="blackTXT">€</span></td><td bgcolor="#F8F8F8"><span class="blackTXT">21%</span><td nowrap bgcolor="#F8F8F8"><span id="result"></span> <span class="blackTXT"><span class="result"></span> €</span><td bgcolor="#F8F8F8"><input type="button" id="remove" value="Remove Row" /> </form></tr></table> '); // Add div to the page $("#container").append(div); // When we type into text area div.find(".num").keyup(function() { // Starting total var total = 1; // Cycle the values and multiply the parsed number div.find(".num").each(function(i, elmn) { total *= Number(elmn.value); }); // Show total div.find(".result").html(total); }); // Trigger keyup when value changes (right-click paste wouldn't be typing) div.find(".num").change($(this).keyup()); }); // Remove button functionality $("#remove").click(function() { $(this).remove("div"); }); }); I can't get the remove button to remove a row....what is wrong? thanks
  5. Hi xaotique, check this out http://www.redbook.es/facturator/test2.php it's a bit messy but I think i got it!!! how can I insert a nice table like the one in my previous script? http://www.redbook.es/facturator/index-2.php Thanks i'm so excited !!!
  6. cool thanks a lot !!!! Will play with it tomorrow cause i'm in Spain and it's quite late here. Stay tuned
  7. just one example please....i'm too new to jquery ...just one
  8. ooops...sorry
  9. here you are http://www.redbook.es/facturator/index-2.php
  10. Thanks that makes sense and it works perfectly as a standalone calculator. Now....I am getting more complicated now..i need this calculator to work as part of my complete script. Would you be so kind to try my script? <html> <head> <?php $referencia= substr(number_format(time() * rand(),0,'',''),0,10); //random number generator ?> <script type="text/javascript" src="../js/calculator.js"></script> <script src="http://code.jquery.com/jquery-1.5.1.min.js"></script> <script> $(document).ready(function() { var id = 0; // usar esto si queremos que la i sea 1, 2, 3 etc var id = (<?php echo $referencia ;?>); // Add button functionality $("table.dynatable button.add").click(function() { id++; var master = $(this).parents("table.dynatable"); // Get a new row based on the prototype row var prot = master.find(".prototype").clone(); prot.attr("class", "") prot.find(".id").attr("value", id); master.find("tbody").append(prot); }); // Remove button functionality $("table.dynatable button.remove").live("click", function() { $(this).parents("tr").remove(); }); }); </script> <style> .dynatable { border: solid 1px #000; border-collapse: collapse; font-family: Arial, Helvetica, sans-serif; font-size: 11px; } .dynatable th, .dynatable td { border: solid 1px #000; text-align: center; color: #FFF; padding-top: 8px; padding-right: 10px; padding-bottom: 8px; padding-left: 10px; } .dynatable .prototype { display:none; } .blackTXT { font-family: Arial, Helvetica, sans-serif; font-size: 11px; color: #333; text-decoration: none; } </style> </head> <body> <table width="901" align="center" class="dynatable"> <thead> <tr> <th width="92" bgcolor="#787878">ID</th> <th width="267" bgcolor="#787878">descripción</th> <th width="120" bgcolor="#787878">cantidad</th> <th width="136" bgcolor="#787878">precio unidad</th> <th width="50" bgcolor="#787878">IVA</th> <th width="73" bgcolor="#787878">total</th> <th width="131" bgcolor="#787878"><button class="add">Add</button></th> </tr> </thead> <tbody> <tr class="prototype"> <form name="form" ><td bgcolor="#F8F8F8"> <input type="ee" class="id" value="<?php echo $referencia?>" size="10" /></td> <td bgcolor="#F8F8F8"><input type="text" id="descripcion[]" size="40" /></td> <td bgcolor="#F8F8F8"><input type="text" class="number" style="width: 100px;"/></td> <td nowrap bgcolor="#F8F8F8"><input type="text" class="number" style="width: 100px;"/> <span class="blackTXT">€</span></td> <td bgcolor="#F8F8F8"><span class="blackTXT">21%</span> <td nowrap bgcolor="#F8F8F8"><span id="result"></span> <span class="blackTXT">€</span> <td bgcolor="#F8F8F8"><button class="remove">Remove</button></form> </tr> </table> </body> </html>
  11. I'm not sure I can do that....could you please give me an example? Thanks
  12. sorry Xaotic one more question, I see your script selects all text inputs to perform the calculation. My problem is I have other text inputs in my form that are not part of the calculation. This is my form <form name="form" ><td bgcolor="#F8F8F8"><input type="text" class="id" size="10" /></td> <td bgcolor="#F8F8F8"><input type="text" id="description[]" size="40" /></td> <td bgcolor="#F8F8F8"><input type="text" id="quantity[]" onchange="doMath()" size="3"/></td> <td bgcolor="#F8F8F8"><input type="text" id="unitprice[]" onchange="doMath()" size="10"/> <td nowrap bgcolor="#F8F8F8"><input type="text" id="total[]" size="10" /> </form> How can I do this? Thanks
  13. Xaotic sorry..ignore my previous post it works fine....Thanks so much!!!!!
  14. Thanx xaotique....the example you link to works fine, but when I try your script it doesn't work This is what i did: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Xaotique</title> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <script type="text/javascript" src="js/calculator.js"></script> </head> <body> <input type="text" style="width: 100px;" /> <input type="text" style="width: 100px;" /> <span id="result"></span> </body> </html> and this is my calculator.js: // This will wait for the page load trigger before our JS runs. window.addEventListener("load", function() { // Select our input boxes containing the numbers to multiply. var input = window.document.querySelectorAll("input"); // Function to calculate. (I guess that's obvious) function calculate() { // Since we're multiplying, a starting total of 1. (anything multiplied by 1 is itself) var total = 1; // Loop through the inputs to deal with the values. for (var i in input) { // Check that the value exists. if (input[i].value != undefined) { // Remove anything but numbers and decimals from the input box. input[i].value = input[i].value.replace(/[^0-9\.]/, ''); // Multiply the number on to our total. total *= Number(input[i].value); } } // Present the total in the area we provided. window.document.querySelector("#result").innerHTML = total; } // Loop through our input boxes. for (var i in input) { // Set default value. input[i].value = 0; // Set trigger to calculate when we press a key. input[i].addEventListener("keyup", calculate, false); // Backup trigger in case of pasting by mouse right-click. input[i].addEventListener("change", calculate, false); } }, false);
  15. Thanx Stephan....but i think your JS is still a bit too complicated for me at this stage. All i need to do is multiply A*B
  16. Hi, I have this form: <form name="form" ><td bgcolor="#F8F8F8"><input type="text" class="id" size="10" /></td> <td bgcolor="#F8F8F8"><input type="text" id="description[]" size="40" /></td> <td bgcolor="#F8F8F8"><input type="text" id="quantity[]" onchange="doMath()" size="3"/></td> <td bgcolor="#F8F8F8"><input type="text" id="unitprice[]" onchange="doMath()" size="10"/> <td nowrap bgcolor="#F8F8F8"><input type="text" id="total[]" size="10" /> </form> What i need to do is to add multiply quantity x unitprice and display the result as total. This is my JS math script: <script type="text/javascript"> function doMath() { // Capture the entered values of two input boxes var quantity = document.getElementById('quantity[]').value; var unitprice = document.getElementById('unitprice[]').value; // Add them together and display var sum = parseInt(quantity[]) * parseInt(unitprice[]); document.getElementById('total[]').value = sum; } </script> But this is not doing the calculation. Please help. thanks
  17. omg akphidelt2007.....I'm such an "·$%&t... Thanks !!!
  18. hi, I have a php mail script that includes html also My problem is that I have to echo some php variables that are inside php tags...how do i do that?. See example in red. If I remove the php tags fromthe variable it does not echo. Please help !!!! <?php $strTo = $_POST["txtTo"]; $strSubject = stripslashes($_POST["txtSubject"]); $strMessage = '<font face="tahoma,arial" size=2>'."Hola\n\n" .$_POST["companyname"]. "<br>alguien ha hecho un pedido:<p>Nombre:\n\n".$_POST["nombre"]."<br>Apellidos:\n\n".$_POST["apellidos"]."<br>Direccion:\n\n".$_POST["tipo_via"].$_POST["nombre_via"]."<br>Ciudad:\n\n".$_POST["poblacion"]."<br>C.P.:\n\n".$_POST["cp"]."<br>Provincia:\n\n".$_POST["provincia"]."<br>Telefono:\n\n".$_POST["telefono"]."<br>Movil:\n\n".$_POST["movil"]."<br>Email:\n\n".$_POST["email"]."<br>Importe Total:\n\n".$totalemail.""; if (!$enersolmaCart->IsEmpty()) { $strMessage.='<h2 style="color:#578557; /* Accent_1 */ margin-bottom:7px; font-size:medium;">Your Shopping Cart</h2> <table width="100%" style=" border-right:solid 1px #CAD0CD; /* Neutral_Medium */ border-left:solid 1px #CAD0CD; /* Neutral_Medium */ border-bottom:solid 1px #CAD0CD; /* Neutral_Medium */ margin-bottom:14px;" border="0" cellspacing="0" cellpadding="0"> <tr> <th style="padding:10px 14px 10px 7px; vertical-align:top; text-align:left; background-color:#578557; /* Accent1 */ color:#FFFFFF; /* Global_White */" text-align:left;>Name</th> <th style="padding:10px 14px 10px 7px; vertical-align:top; text-align:right; background-color:#578557; /* Accent1 */ color:#FFFFFF; /* Global_White */" text-align:right;>Price</th> <th style="padding:10px 14px 10px 7px; vertical-align:top; text-align:right; background-color:#578557; /* Accent1 */ color:#FFFFFF; /* Global_White */" text-align:right;>Shipping</th> <th style="padding:10px 14px 10px 7px; vertical-align:top; text-align:right; background-color:#578557; /* Accent1 */ color:#FFFFFF; /* Global_White */" text-align:right;>IVA</th> <th style="padding:10px 14px 10px 7px; vertical-align:top; text-align:right; background-color:#578557; /* Accent1 */ color:#FFFFFF; /* Global_White */" text-align:right;>Total</th> </tr>'; while (!$enersolmaCart->EOF()) { $strMessage.=' <tr> <td style="padding:10px 14px 10px 7px; vertical-align:top;" ><?php echo $enersolmaCart->DisplayInfo("Name"); ?></td> <td style="padding:10px 14px 10px 7px; vertical-align:top; text-align:right;" >[color=#FF0000]<?echo WA_eCart_DisplayMoney($enersolmaCart, $enersolmaCart->DisplayInfo("Price")); ?>[/color][color=#000000]</td[/color]> <td style="padding:10px 14px 10px 7px; vertical-align:top; text-align:right;" ><?php echo WA_eCart_DisplayMoney($enersolmaCart, $enersolmaCart->DisplayInfo("Shipping")); ?></td> <td style="padding:10px 14px 10px 7px; vertical-align:top; text-align:right;" ><?php echo WA_eCart_DisplayMoney($enersolmaCart, $enersolmaCart->DisplayInfo("IVA")); ?></td> <td style="padding:10px 14px 10px 7px; vertical-align:top; text-align:right;" ><?php echo WA_eCart_DisplayMoney($enersolmaCart, $enersolmaCart->DisplayInfo("TotalPrice")); ?></td> </tr>'; php?>
  19. weird... i was including the php file where all my constants are defined at the top of each page like so: include ('../constants.php'); I have changed this to include ('constants.php'); ..and it works now !!!. How come....my constants.php file is one dir up...
  20. all my constants ae defined on a separate file that i include on each page. This is the code for the constant define ('CNT_TXT_EMPTYMESSAGE',"Your cart is empty");
  21. No jc, the constant is not empty
  22. hi, I have the PHP code below wher I'm trying to echo the contant CNT_TXT_EMPTYMESSAGE. i have trie everything...with double quotes...single...with nothing...everything but nothing seems to work. Am i using the correct syntax to do this? Many thanks <?php include_once('config.php'); if (!$config['currencyCode']) $config['currencyCode'] = 'EUR'; if (!$config['text']['cartTitle']) $config['text']['cartTitle'] = 'Shopping Cart'; if (!$config['text']['singleItem']) $config['text']['singleItem'] = 'Item'; if (!$config['text']['multipleItems']) $config['text']['multipleItems'] = 'Items'; if (!$config['text']['subtotal']) $config['text']['subtotal'] = 'Subtotal'; if (!$config['text']['update']) $config['text']['update'] = 'update'; if (!$config['text']['checkout']) $config['text']['checkout'] = 'checkout'; if (!$config['text']['checkoutPaypal']) $config['text']['checkoutPaypal'] = 'Checkout with PayPal'; if (!$config['text']['removeLink']) $config['text']['removeLink'] = 'remove'; if (!$config['text']['emptyButton']) $config['text']['emptyButton'] = 'empty'; if (!$config['text']['emptyMessage']) $config['text']['emptyMessage'] = '.CNT_TXT_EMPTYMESSAGE.'; if (!$config['text']['itemAdded']) $config['text']['itemAdded'] = 'Item added!'; if (!$config['text']['priceError']) $config['text']['priceError'] = 'Invalid price format!'; if (!$config['text']['quantityError']) $config['text']['quantityError'] = 'Item quantities must be whole numbers!'; if (!$config['text']['checkoutError']) $config['text']['checkoutError'] = 'Your order could not be processed!'; if ($_GET['ajax'] == 'true') { header('Content-type: application/json; charset=utf-8'); echo json_encode($config); } ?>
  23. kicken and Eritrea, sorry I missed your replies....will try both your suggestions and come back ...thanks
  24. Hi, this is my query here $colname_cats_RS = "-1"; if (isset($_GET['id_categoria'])) { $colname_cats_RS = $_GET['id_categoria']; } mysql_select_db($database_MySQLconnect, $MySQLconnect); $query_cats_RS = sprintf("SELECT * FROM t_subcategorias WHERE id_categoria = %s", GetSQLValueString($colname_cats_RS, "int")); $cats_RS = mysql_query($query_cats_RS, $MySQLconnect) or die(mysql_error()); $row_cats_RS = mysql_fetch_assoc($cats_RS); $totalRows_cats_RS = mysql_num_rows($cats_RS); and this is how I echo the results <?php echo $row_cats_RS['subcategoria_esp']; ?> What I need to do is to display the record count for each subcategory like for example: red (5) blue(2) etc.... Please help me :-)
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.