Jump to content

vincej

Members
  • Posts

    155
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling
  • Location
    Calgary , Canada

vincej's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. I am new to Javascript, so please forgive me if this is a dumb question See attached screen shot. My JS code computes the value of "cost" and it sets it into the input of a a form using row.val(cost). When it has calculated all the costs for all the products, adding, subtracting and multiplying, I want to find the total. So, I now scan through all the cost inputs using an "each" method and create a sum total. Problem: the calculated cost inputs are visible on the screen. If a user changes their mind about the quantity required on a particular line item, the grand total must be recalculated. However the line totals are calculated. Therefore, they do not appear in the source code, so, I can not grab them using the selector $("input.cost") Question: How do I grab the values of the computed cost values which are visible in the input fields? row.data('price') // THIS IS DECLARED IN AN EARLIER FUNCTION. var runningTotal = 0; // THIS IS DECLARED AS A GLOBAL $("input.quantity").on('change', function() { var row = $(this).parents(':eq(1)').find('input').filter(".cost"); var price = row.data('price'); if (price) { var quantity = parseFloat($(this).val()); var cost = (price * quantity); row.val(cost); // COST INSERTED HERE!! $("input.cost").each(function(){ var ic = $(this).val(); // TRIED USING HTML AND TEXT METHODS. var inputCost = Number(ic); runningTotal += inputCost; }); $("#total").val(runningTotal); } HTML for a typical row: ( I am using Laravel Blade, however this is the rendered HTML) <div class="well form-group "> <div class="col-sm-2 col-md-2"><label for="underlay2">Underlayments:</label></div> <div class="col-sm-4 col-md-4"><select class="form-control product_id" name="product_code[4]"><option selected="selected" value="">None</option><option value="789">BP #15 Plain Felt 36" | $10.00</option><option value="790">BP #30 Plain Felt 36" | $10.00</option></select></div> <div class="col-sm-1 col-md-1"><label for="underlay2_req">Quantity:</label></div> <div class="col-sm-2 col-md-2"><input class="form-control quantity" name="quantity[4]" type="text"></div> <div class="col-sm-1 col-md-1"><label for="cost">Cost:</label></div> <div class="col-sm-2 col-md-2"><input class="form-control cost" readonly="readonly" name="cost[0]" type="text" value=""></div> </div>
  2. I work with PHP and I'm not good with JS. I want to use a Twitter Boostrap tab funnction: http://getbootstrap.com/javascript/#tabs I need some guidance how it uses the JS code mentioned. The code below taken from the Bootstrap page is obvious enough: $('#myTab a').click(function (e) { e.preventDefault() $(this).tab('show') }) What I do not understand is how I am required to use the following code in the context of the previous code. Ok, I get that I have to choose one option, but I don't get how they fit together and I do not get how I can have 5-7 tabs and how they will be highlighted one after the other as per the given example on the Bootstrap page : $('#myTab a[href="#profile"]').tab('show') // Select tab by name $('#myTab a:first').tab('show') // Select first tab $('#myTab a:last').tab('show') // Select last tab $('#myTab li:eq(2) a').tab('show') // Select third tab (0-indexed) Many thanks for all your help !
  3. Hi - My app is built with Codeigniter and so if I turn on CSRF on CI inside the config I get the token being created on my page - good. But I have 1 page ( "shopping cart") which uses Scriptaculous Ajax.Updater function : http://api.prototypejs.org/ajax/Ajax/Updater/ When I turn on CSRF my shopping cart page refuses to function in terms of updating the cart or deleting any items from the cart. These are both js functions. I am really stuck - any help would be a God send. Thank You !! Here is the code: UpDate JS Function: function jsUpdateCart(){ var parameter_string = ''; allNodes = document.getElementsByClassName("process"); for(i = 0; i < allNodes.length; i++) { var tempid = allNodes[i].id; var temp = new Array; temp = tempid.split("_"); var real_id = temp[2]; var real_value = allNodes[i].value; parameter_string += real_id +':'+real_value+','; } var params = 'ids='+parameter_string; var ajax = new Ajax.Updater( 'ajax_msg','http://localhost/mysite/index.php/welcome/ajax_cart', {method:'post',parameters:params,onComplete:showMessage} ); }
  4. Yup, the nice person left some friendly messages just to prove it. Now i need to recover. I have back up code and DB. But I need to establish what kind of hack it was and how to improve things. The big tell tale, is that all the javascript is gone off the pages. Yet the js tools ( jquery etc ) all all still there. They also got past the login page as well. The site was built with CodeIgniter so I had invested my trust in the framework as I will never assume I know more than the CI guys on security. any ideas jump to mind as to what kind of hack it was and therefore what obvious things I can do to avoid it again ? Many Thanks !!
  5. YOU ARE A MEGA STAR - THANK YOU SO MUCH !! Part of my problem was that I was use % widths rather than an absolute width. So far I have not seen any adverse effects needing tidying up . Cheers !
  6. Hi Guys - Many thanks for your advice so far. But sadly I continue to fail in getting it right. I have just today put the pre-production site up on a subdomain: http://parish.jacobssoftwareanddesign.com/ Can you have a look at the drop down "the parish" and see what stupid thing I am misssing on the sub menu - all I want is that the white background extends across the width of the dropdown when you hover over it. Many Many Thanks !!
  7. Hi - I'm normally pretty good with css, but this time I am defeated. All I want is the white background behind the Navigation label extends right across the dropdown box. I have done the usual: checked the padding and margin. Also tried extending the width of the a tag and nothing works. When I make changes to these css selectors in Firebug they get crossed through. However, I can not see any other active value in the Firebug css listing which impacts the background color. Ok - you can not see the rest of the css style sheet, but under normal conditions what usually works given that each Nav label is slightly different in length ?? Many Many Thanks !
  8. Fair comment, yes, well pointed out - I will only want immediately descendants however, I do want to see all ancestors, such that t he click can jump multiple steps up the tree in one hit. I'm not sure the best way to hold the data ie one node at a time or all in a single big array. I have it working in a cms ( ExpressionEngine) using an extension. But I want to move off ExpressionEngine and recreate it in PHP somewhere else. You can see it in a sandbox environment : http://jacobssoftwareanddesign.com/angelsroofing/index.php/sub_category/roofing Many Thanks !
  9. @requinix I will rarely need to add or remove categories. And I will never only want immediate ancestors or descendants One thing that I omitted to mention is that, the number of levels will be of a fixed and known in advance. I need to go down 5 levels. so for example: Fruit -> Red -> Apples -> Californian -> Red Delicious | Galla | Jersey Mac | -- 5 levels So, if I click "Fruit" I might see "Fruit | Red | Green | Yellow" all in tabs -- current Root level + the next level If I click "Red" I might see "Fruit | Red | Californian | Mexican | Florida all in tabs -- 1 ancestor + next level of descendents If I click "California" I might see "Fruit | Red | Apples | Californian | Red Delicious | Galla | Jersey Mac " -- 3 ancestors + next level of descendants So the point is the customer can see where he has come from ( ancestors) and where he can go ( descendent ) and with 1 click jump straight back to "Red" if they choose. Also they can see the descendants beyond where they are as well. So I am thinking a 5 way multi-dimensional array. I can populate the array in hard code. Where I am coming unstuck is is how best to dynamically pull the correct content out of the array based on what the user clicks. Many Many Thanks for your Help !
  10. Hi - I am struggling to find a solution to a category problem. Perhaps I am over thinking this. I need to display a navigation menu in tabs so that as you tab through the hierarchy you can see the categories in the hierarchy both above and below where you currently are. Conceptually I found an architectural solution on Sitepoint called, Modified Preorder Tree Traversal - but it is quite complex and I was hoping for something a little easier. In simple terms I need to be able to search and display all the categories and sub categories going up or down the category hierarchy. It could be as much as 5 levels deep. My need is 3 fold: 1 - starting at the root I have to find all the descendants. 2 - if you start at the bottom of the hierarchy, I need to find all the ancestors. 3 - Worst of all ... if you start half way down the hierarchy, I need to display both all the ancestors and all the descendants. Does anyone have some advice or resources I should consider ?? MANY MANY Thanks !
  11. HI - I have my Codeigniter / PHP dev. machine in one room where I can of course test just using "localhost". However, I have a laptop in another room, where I would like to also be able to do occaisional development from without uploading the files to that local machine. I have mapped a drive to the remote machine and I can see the files. I Want to be able to point my laptop browser at the remote system and see the render files on my laptop. Any ideas how I do that ? Many thanks !
  12. First of all I'm not even sure if it's the query I need help with or with the PHP. Here is the situation. I have built an app. The app has a report which generates a list of all the products sold with the quantity and price for each location. The problem I have is that every line item has it's location repeated, and repeated - this is the consequence of the foreach loop used. so for example: Chicago 200 chickens $2000 Chicago 100 hams $1000 Chicago 300 Beef $6000 You can see the problem ... Chicago is repeated on every line. What is even more boring is that the document reports on 50 cities with 50 products each. So there is immense repetition. So I want to get to is: Chicago 200 chickens $2000 100 hams $1000 300 Beef $6000 Washington 200 chickens $2000 100 hams $1000 300 Beef $6000 etc etc Here is the SQL I have delivering the flawed outcome: SELECT products.name, order.prodid, sum(order.quantity) as 'Quantity', order.pickupdate, sum(order.ordervalue) as 'Order Value', locations.location, locations.locationid FROM `products`, `order`, `locations` where order.prodid = products.id and locations.locationid = order.deliverylocationid AND order.status = 'open' group by order.deliverylocationid, order.prodid order by locations.location asc; Here is the Foreach Loops which generates the results of the flawed result: <?php foreach ($ordersbylocation as $key => $value){ ?> <tr> <td width="150"><?php echo anchor('admin/reports/SpecificLocation/' . $value['locationid'], $value['location']);?></td> <td width="60" align="center"><?php echo $value['prodid'];?></td> <td width="60" align="center"><?php echo $value['Quantity'];?></td> <td width="250"><?php echo $value['name'];?></td> <td width="150"><?php echo $value['Order Value'] . "<br>";?></td> </tr> <?php } ?>
  13. Thanks !! Your advice caused me to search through my code ...I found a change .. commented it out adn bingo - fixed . Now I have to figure out why that snippet of code caused the failure in the first place.
  14. yes - I guess so , bu there was so much stuff going on at that time that I can not figure out what it might have been - Please tell me, should I bee looking at the a page and supporting code for the one that failed or the referer page ?
  15. Thanks for your comments. Yes things changed, however, the code runs fine on my XAMPP dev sys , but when it goes to the ISP it fails. Can you tell me what I should be looking for ?? I use PHPStorm as my editor and it usually is very good at highlighting errors but there is nothing. I don't even know where to start looking. MANY thanks !
×
×
  • 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.