Search Results

Search found 8083 results on 324 pages for 'total newbie'.

Page 24/324 | < Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >

  • Print all ways to sum n integers so that they total a given sum.

    - by noghead
    Im trying to come up with an algorithm that will print out all possible ways to sum N integers so that they total a given value. Example. Print all ways to sum 4 integers so that they sum up to be 5. Result should be something like: 5 0 0 0 4 1 0 0 3 2 0 0 3 1 1 0 2 3 0 0 2 2 1 0 2 1 2 0 2 1 1 1 1 4 0 0 1 3 1 0 1 2 2 0 1 2 1 1 1 1 3 0 1 1 2 1 1 1 1 2

    Read the article

  • SAN newbie: What kind of fiber cables do I need to connect to the front end ports on my EMC CX300

    - by red888
    I have an old CX300 I'm messing with and I cant determine what kind of HBA\fiber cables I need to connect a server to the front end ports on the DPE2. The hardware reference doesn't give me any details and being new to FC-SAN all of the options are pretty overwhelming. I don't know if the ports are SC or LC or if it requires singlemode or multimode. Googling hasn't turned up anything for me either. All I know is that it supports 2GB Fiber. Here is a pic of one the modules. You can clearly see the front-end ports (FE)

    Read the article

  • Newbie ask Swap Value: How much Swap do I have?

    - by Cintaku
    When looking vmstat, this is what I got: procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------ r b swpd free buff cache si so bi bo in cs us sy id wa st 1 0 0 2872 0 0 0 0 8 17 0 14 3 1 94 2 0 the cache is 0. I have no idea how much the whole swap I have. But when not enough RAM (256 MB), the swap will be used and look like below: procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------ r b swpd free buff cache si so bi bo in cs us sy id wa st 3 1 2468 0 0 0 0 0 8 17 0 16 3 1 94 2 0

    Read the article

  • What would be the total expenses of running an in-home web server?

    - by techaddict
    I have several hosting accounts with companies, and plan to keep them. However, I would like to try my hand at creating my own home web-server, both for fun and for the learning experience. I would like to know the expenses involved, including: electricity costs (greater than light bulb?) internet costs (will I have to upgrade my internet? Or is 3-5Mbps upload speed fine for a web server with medium amount of traffic? Would I have to get a separate internet connection?) other unknown expenses Consider that I will configure the web server myself, so that is not an expense. Also consider that I already have a computer (year-old Dell laptop, 15R) to use to be dedicated as the web server.

    Read the article

  • How ssl is usually set up on shared hosting (newbie question)?

    - by spirytus
    I am quite unclear on how ssl is usually set up on shared hosting. I have account with justhost.com and they provided me with public_html folder and (its sibling) ssl folder. When I create ssl certificates via cPanel it appears in SSL folder. Now, where I should put my html files to be accessible via https:// rather than http? normal files go into public_html (I figured this out ;) what about secure bunch? Also how can I specify that secured folder shouldn't be the ssl folder (if its the one in fact) but rather some other folder I specify? Is it possible at all with shared hosting? Thank you all for your help, I googled for hours and still am heavily confused as you see :)

    Read the article

  • Forcing user to new page in php. (PHP newbie)

    - by JohnC
    Hello I'm a newbie web programmer. My background is writing Windows applications with sql. I'm putting together my 1st data entry screens in Php. I have a search form that links to a form that displays records in a grid. On each row of the grid I have a delete url to allow the user to remove a record. This links to a form delete.php (which calls the sql to remove the record). Ideally I would like to automatically take the user back to the search form rather than forcing the user to click on a link to do so. I have used ob_start with the header to do this elsewhere but cannot get it to work on this page. Is there another way to do it? (Using php 5 as part of LAMP) file delete.php <?php $id = $_GET['recordID']; //ob_start(); require_once('connections/local.php'); mysql_select_db($database_local, $local); mysql_query("DELETE FROM user_access WHERE id = {$id}") or die(mysql_error()); echo("Record ".$id." deleted"); echo("<br>"); //header("location:http://localhost/search7.htm); //ob_flush(); echo("<a href=\"http://localhost/search7.htm\">Search for Members</a>"); ?>

    Read the article

  • Is it possible to make a MS-SQL Scalar function do this?

    - by Hokken
    I have a 3rd party application that can call a MS-SQL scalar function to return some summary information from a table. I was able to return the summary values with a table-valued function, but the application won't utilize table-valued functions, so I'm kind of stuck. Here's a sample from the table: trackingNumber, projTaskAward, expenditureType, amount 1122, 12345-67-89, Supplies, 100 1122, 12345-67-89, Supplies, 150 1122, 12345-67-89, Supplies, 250 1122, 12345-67-89, Misc, 50 1122, 12345-67-89, Misc, 100 1122, 98765-43-21, General, 200 1122, 98765-43-21, Conference, 500 1122, 98765-43-21, Misc, 300 1122, 98765-43-21, Misc, 100 1122, 98765-43-21, Misc, 100 I want to summarize the amounts by projTaskAward & expenditureType, based on the trackingNumber. Here is the output I'm looking for: Proj/Task/Award: 12345-67-89 Expenditure Type: Supplies Total: 500 Proj/Task/Award: 12345-67-89 Expenditure Type: Misc Total: 150 Proj/Task/Award: 98765-43-21 Expenditure Type: General Total: 200 Proj/Task/Award: 98765-43-21 Expenditure Type: Conference Total: 500 Proj/Task/Award: 98765-43-21 Expenditure Type: Misc Total: 500 I'd appreciate any help anyone can give in steering me in the right direction.

    Read the article

  • got undefined variable in php code

    - by Newbie New
    I got a error message when I run my php however the result is come out this is my code function cart() { foreach($_SESSION as $name => $value) { if ($value>0) { if (substr($name, 0, 5) == 'cart_'){ $id = substr($name, 5, (strlen($name)-5)); $get = mysql_query('SELECT id, name, price FROM products WHERE id=' .mysql_real_escape_string((int)$id)); while ($get_row = mysql_fetch_assoc($get)){ $sub = $get_row['price'] * $value; echo $get_row['name'].' x '.$value.' @ &pound'.number_format($get_row['price'], 2).' = &pound'.number_format($sub, 2).' <a href="cart.php?remove='.$id.'">[-]</a> <a href="cart.php?add='.$id.'">[+]</a> <a href="cart.php?delete='.$id.'">[Delete]</a><br />' ; } } $total += $sub; } } echo $total; } ?> I got a error message Notice: Undefined variable: total in C:\xampp\htdocs\shoppingcart\cart.php on line 54 which line 54 is echo $total; what's wrong with my code?? I think I have defined the code in $total += $sub; thanks for helping me :)

    Read the article

  • How to compare page views/visitors to site totals in Google Analytics?

    - by frntk
    I want to measure the effects in total traffic (views or visitors) of a single URL across a time frame. For example, let's say I published a blog post on July 2012. I want to measure what chunk of the site's total traffic is coming to this particular post on a month-by-month graph from July 2012 to date. Is there a way to do this? Edit: I should clarify that what I'd like to do is to generate a month-to-month graph, similar to the one you can see comparing a metric on a period of time against the previous equivalent period (year vs last year, for example) but comparing a particular URL traffic to the site's total traffic. In other words, I can get to the part where I can see the URL's traffic for the timeframe I selected and it shows how much of the total traffic corresponds to the current URL: But I'd like to add a second line to the graph, representing the site's total pageviews, similiar to this (but this one is showing just a different metric for the same URL): Thanks!

    Read the article

  • Opencart Dashboard show last months statistics

    - by John Magnolia
    How could I added the option to show the statistics for last month. PHP public function chart() { $this->load->language('common/home'); $data = array(); $data['order'] = array(); $data['customer'] = array(); $data['xaxis'] = array(); $data['order']['label'] = $this->language->get('text_order'); $data['customer']['label'] = $this->language->get('text_customer'); if (isset($this->request->get['range'])) { $range = $this->request->get['range']; } else { $range = 'month'; } switch ($range) { case 'day': for ($i = 0; $i < 24; $i++) { $query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id > '0' AND (DATE(date_added) = DATE(NOW()) AND HOUR(date_added) = '" . (int)$i . "') GROUP BY HOUR(date_added) ORDER BY date_added ASC"); if ($query->num_rows) { $data['order']['data'][] = array($i, (int)$query->row['total']); } else { $data['order']['data'][] = array($i, 0); } $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer WHERE DATE(date_added) = DATE(NOW()) AND HOUR(date_added) = '" . (int)$i . "' GROUP BY HOUR(date_added) ORDER BY date_added ASC"); if ($query->num_rows) { $data['customer']['data'][] = array($i, (int)$query->row['total']); } else { $data['customer']['data'][] = array($i, 0); } $data['xaxis'][] = array($i, date('H', mktime($i, 0, 0, date('n'), date('j'), date('Y')))); } break; case 'week': $date_start = strtotime('-' . date('w') . ' days'); for ($i = 0; $i < 7; $i++) { $date = date('Y-m-d', $date_start + ($i * 86400)); $query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id > '0' AND DATE(date_added) = '" . $this->db->escape($date) . "' GROUP BY DATE(date_added)"); if ($query->num_rows) { $data['order']['data'][] = array($i, (int)$query->row['total']); } else { $data['order']['data'][] = array($i, 0); } $query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "customer` WHERE DATE(date_added) = '" . $this->db->escape($date) . "' GROUP BY DATE(date_added)"); if ($query->num_rows) { $data['customer']['data'][] = array($i, (int)$query->row['total']); } else { $data['customer']['data'][] = array($i, 0); } $data['xaxis'][] = array($i, date('D', strtotime($date))); } break; default: case 'month': for ($i = 1; $i <= date('t'); $i++) { $date = date('Y') . '-' . date('m') . '-' . $i; $query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id > '0' AND (DATE(date_added) = '" . $this->db->escape($date) . "') GROUP BY DAY(date_added)"); if ($query->num_rows) { $data['order']['data'][] = array($i, (int)$query->row['total']); } else { $data['order']['data'][] = array($i, 0); } $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer WHERE DATE(date_added) = '" . $this->db->escape($date) . "' GROUP BY DAY(date_added)"); if ($query->num_rows) { $data['customer']['data'][] = array($i, (int)$query->row['total']); } else { $data['customer']['data'][] = array($i, 0); } $data['xaxis'][] = array($i, date('j', strtotime($date))); } break; case 'year': for ($i = 1; $i <= 12; $i++) { $query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "order` WHERE order_status_id > '0' AND YEAR(date_added) = '" . date('Y') . "' AND MONTH(date_added) = '" . $i . "' GROUP BY MONTH(date_added)"); if ($query->num_rows) { $data['order']['data'][] = array($i, (int)$query->row['total']); } else { $data['order']['data'][] = array($i, 0); } $query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer WHERE YEAR(date_added) = '" . date('Y') . "' AND MONTH(date_added) = '" . $i . "' GROUP BY MONTH(date_added)"); if ($query->num_rows) { $data['customer']['data'][] = array($i, (int)$query->row['total']); } else { $data['customer']['data'][] = array($i, 0); } $data['xaxis'][] = array($i, date('M', mktime(0, 0, 0, $i, 1, date('Y')))); } break; } $this->response->setOutput(json_encode($data)); } HTML <select name="range"> <option value="day">Today</option> <option value="week">This Week</option> <option value="month">This Month</option> <option value="year">This Year</option> </select>

    Read the article

  • Entry lvl. COBOL Control Breaks

    - by Kyle Benzle
    I'm working in COBOL with a double control break to print a hospital record. The input is one record per line, with, hospital info first, then patient info. There are multiple records per hospital, and multiple services per patient. The idea is, using a double control break, to print one hospital name, then all the patients from that hospital. Then print the patient name just once for all services, like the below. I'm having trouble with my output, and am hoping someone can help me get it in order. I am using AccuCobol to compile experts-exchange does not allow .cob and .dat so the extentions were changed to .txt The files are: the .cob lab5b.cob the input / output: lab5bin.dat, lab5bout.dat The assignment: http://www.cse.ohio-state.edu/~sgomori/314/lab5.html Hospital Number: 001 Hospital Name: Mount Carmel 00001 Griese, Brian Ear Infection 08/24/1999 300.00 Diaper Rash 09/05/1999 25.00 Frontal Labotomy 09/25/1999 25,000.00 Rear Labotomy 09/26/1999 25,000.00 Central Labotomy 09/28/1999 24,999.99 The total amount owed for this patient is: $.......... (End of Hospital) The total amount owed for this hospital is: $......... enter code here IDENTIFICATION DIVISION. PROGRAM-ID. LAB5B. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE-CONTROL. SELECT FILE-IN ASSIGN TO 'lab5bin.dat' ORGANIZATION IS LINE SEQUENTIAL. SELECT FILE-OUT ASSIGN TO 'lab5bout.dat' ORGANIZATION IS LINE SEQUENTIAL. DATA DIVISION. FILE SECTION. FD FILE-IN. 01 HOSPITAL-RECORD-IN. 05 HOSPITAL-NUMBER-IN PIC 999. 05 HOSPITAL-NAME-IN PIC X(20). 05 PATIENT-NUMBER-IN PIC 99999. 05 PATIENT-NAME-IN PIC X(20). 05 SERVICE-IN PIC X(30). 05 DATE-IN PIC 9(8). 05 OWED-IN PIC 9(7)V99. FD FILE-OUT. 01 REPORT-REC-OUT PIC X(100). WORKING-STORAGE SECTION. 01 WS-WORK-AREAS. 05 WS-HOLD-HOSPITAL-NUM PIC 999 VALUE ZEROS. 05 WS-HOLD-PATIENT-NUM PIC 99999 VALUE ZEROS. 05 ARE-THERE-MORE-RECORDS PIC XXX VALUE 'YES'. 88 MORE-RECORDS VALUE 'YES'. 88 NO-MORE-RECORDS VALUE 'NO '. 05 FIRST-RECORD PIC XXX VALUE 'YES'. 05 WS-PATIENT-TOTAL PIC 9(9)V99 VALUE ZEROS. 05 WS-HOSPITAL-TOTAL PIC 9(9)V99 VALUE ZEROS. 05 WS-PAGE-CTR PIC 99 VALUE ZEROS. 01 WS-DATE. 05 WS-YR PIC 9999. 05 WS-MO PIC 99. 05 WS-DAY PIC 99. 01 HL-HEADING1. 05 PIC X(49) VALUE SPACES. 05 PIC X(14) VALUE 'OHIO INSURANCE'. 05 PIC X(7) VALUE SPACES. 05 HL-PAGE PIC Z9. 05 PIC X(14) VALUE SPACES. 05 HL-DATE. 10 HL-MO PIC 99. 10 PIC X VALUE '/'. 10 HL-DAY PIC 99. 10 PIC X VALUE '/'. 10 HL-YR PIC X VALUE '/'. 01 HL-HEADING2. 05 PIC XXXXXXXXXX VALUE 'HOSPITAL: '. 05 HL-HOSPITAL PIC 999. 01 HL-HEADING3. 05 PIC X(7) VALUE "Patient". 05 PIC X(3) VALUE SPACES. 05 PIC X(7) VALUE "Patient". 05 PIC X(39) VALUE SPACES. 05 PIC X(7) VALUE "Date of". 05 PIC X(3) VALUE SPACES. 05 PIC X(6) VALUE "Amount". 01 HL-HEADING4. 05 PIC X(6) VALUE "Number". 05 PIC X(4) VALUE SPACES. 05 PIC X(4) VALUE "Name". 05 PIC X(18) VALUE SPACES. 05 PIC X(10) VALUE "Service". 05 PIC X(14) VALUE SPACES. 05 PIC X(8) VALUE "Service". 05 PIC X(2) VALUE SPACES. 05 PIC X(5) VALUE "Owed". 01 DL-PATIENT-LINE. 05 PIC X(28) VALUE SPACES. 05 DL-PATIENT-NUMBER PIC XXXXX. 05 PIC X(21) VALUE SPACES. 05 DL-PATIENT-TOTAL PIC $$$,$$$,$$9.99. 01 DL-HOSPITAL-LINE. 05 PIC X(47) VALUE SPACES. 05 PIC X(16) VALUE 'HOSPITAL TOTAL: '. 05 DL-HOSPITAL-TOTAL PIC $$$,$$$,$$9.99. PROCEDURE DIVISION. 100-MAIN-MODULE. PERFORM 600-INITIALIZATION-RTN PERFORM UNTIL NO-MORE-RECORDS READ FILE-IN AT END MOVE 'NO ' TO ARE-THERE-MORE-RECORDS NOT AT END PERFORM 200-DETAIL-RTN END-READ END-PERFORM PERFORM 400-HOSPITAL-BREAK PERFORM 700-END-OF-JOB-RTN STOP RUN. 200-DETAIL-RTN. EVALUATE TRUE WHEN FIRST-RECORD = 'YES' MOVE PATIENT-NUMBER-IN TO WS-HOLD-PATIENT-NUM MOVE HOSPITAL-NUMBER-IN TO WS-HOLD-HOSPITAL-NUM PERFORM 500-HEADING-RTN MOVE 'NO ' TO FIRST-RECORD WHEN HOSPITAL-NUMBER-IN NOT = WS-HOLD-HOSPITAL-NUM PERFORM 400-HOSPITAL-BREAK WHEN PATIENT-NUMBER-IN NOT = WS-HOLD-PATIENT-NUM PERFORM 300-PATIENT-BREAK END-EVALUATE ADD OWED-IN TO WS-PATIENT-TOTAL. 300-PATIENT-BREAK. MOVE WS-PATIENT-TOTAL TO DL-PATIENT-TOTAL MOVE WS-HOLD-PATIENT-NUM TO DL-PATIENT-NUMBER WRITE REPORT-REC-OUT FROM DL-PATIENT-LINE AFTER ADVANCING 2 LINES ADD WS-PATIENT-TOTAL TO WS-HOSPITAL-TOTAL IF MORE-RECORDS MOVE ZEROS TO WS-PATIENT-TOTAL MOVE PATIENT-NUMBER-IN TO WS-HOLD-PATIENT-NUM END-IF. 400-HOSPITAL-BREAK. PERFORM 300-PATIENT-BREAK MOVE WS-HOSPITAL-TOTAL TO DL-HOSPITAL-TOTAL WRITE REPORT-REC-OUT FROM DL-HOSPITAL-LINE AFTER ADVANCING 2 LINES IF MORE-RECORDS MOVE ZEROS TO WS-HOSPITAL-TOTAL MOVE HOSPITAL-NUMBER-IN TO WS-HOLD-HOSPITAL-NUM PERFORM 500-HEADING-RTN END-IF. 500-HEADING-RTN. ADD 1 TO WS-PAGE-CTR MOVE WS-PAGE-CTR TO HL-PAGE MOVE WS-HOLD-HOSPITAL-NUM TO HL-HOSPITAL WRITE REPORT-REC-OUT FROM HL-HEADING1 AFTER ADVANCING PAGE WRITE REPORT-REC-OUT FROM HL-HEADING2 AFTER ADVANCING 2 LINES. WRITE REPORT-REC-OUT FROM HL-HEADING3 AFTER ADVANCING 2 LINES. 600-INITIALIZATION-RTN. OPEN INPUT FILE-IN OUTPUT FILE-OUT *159 ACCEPT WS-DATE FROM DATE YYYYMMDD MOVE WS-YR TO HL-YR MOVE WS-MO TO HL-MO MOVE WS-DAY TO HL-DAY. 700-END-OF-JOB-RTN. CLOSE FILE-IN FILE-OUT.

    Read the article

  • Total Order between !different! volatile variables?

    - by andreas
    Hi all, Consider the following Java code: volatile boolean v1 = false; volatile boolean v2 = false; //Thread A v1 = true; if (v2) System.out.println("v2 was true"); //Thread B v2 = true; if (v1) System.out.println("v1 was true"); If there was a globally visible total order for volatile accesses then at least one println would always be reached. Is that actually guaranteed by the Java Standard? Or is an execution like this possible: A: v1 = true; B: v2 = true; A: read v2 = false; B: read v1 = false; A: v2 = true becomes visible (after the if) B: v1 = true becomes visible (after the if) I could only find statements about accesses to the same volatile variable in the Standard (but I might be missing something). "A write to a volatile variable (§8.3.1.4) v synchronizes-with all subsequent reads of v by any thread (where subsequent is defined according to the synchronization order)." http://java.sun.com/docs/books/jls/third_edition/html/memory.html#17.4.4 Thanks!

    Read the article

  • How can I get the rank of rows relative to total number of rows based on a field?

    - by Arms
    I have a scores table that has two fields: user_id score I'm fetching specific rows that match a list of user_id's. How can I determine a rank for each row relative to the total number of rows, based on score? The rows in the result set are not necessarily sequential (the scores will vary widely from one row to the next). I'm not sure if this matters, but user_id is a unique field. Edit @Greelmo I'm already ordering the rows. If I fetch 15 rows, I don't want the rank to be 1-15. I need it to be the position of that row compared against the entire table by the score property. So if I have 200 rows, one row's rank may be 3 and another may be 179 (these are arbitrary #'s for example only). Edit 2 I'm having some luck with this query, but I actually want to avoid ties SELECT s.score , s.created_at , u.name , u.location , u.icon_id , u.photo , (SELECT COUNT(*) + 1 FROM scores WHERE score > s.score) AS rank FROM scores s LEFT JOIN users u ON u.uID = s.user_id ORDER BY s.score DESC , s.created_at DESC LIMIT 15 If two or more rows have the same score, I want the latest one (or earliest - I don't care) to be ranked higher. I tried modifying the subquery with AND id > s.id but that ended up giving me an unexpected result set and different ties.

    Read the article

  • Newbie - what do I need to do with httpd.conf to make CakePHP work correctly?

    - by EmmyS
    (Not sure if this belongs here or on webmasters; please move if necessary.) I'm a total newbie to Cake and not much better with apache; I've done a lot of PHP but always with a server that's already been set up by someone else. So I'm going through the basic blog tutorial, and it says: A Note On mod_rewrite Occasionally a new user will run in to mod_rewrite issues, so I'll mention them marginally here. If the Cake welcome page looks a little funny (no images or css styles), it probably means mod_rewrite isn't functioning on your system. Here are some tips to help get you up and running: Make sure that an .htaccess override is allowed: in your httpd.conf, you should have a section that defines a section for each Directory on your server. Make sure the AllowOverride is set to All for the correct Directory. Make sure you are editing the system httpd.conf rather than a user- or site-specific httpd.conf. For some reason or another, you might have obtained a copy of CakePHP without the needed .htaccess files. This sometimes happens because some operating systems treat files that start with '.' as hidden, and don't copy them. Make sure your copy of CakePHP is from the downloads section of the site or our SVN repository. Make sure you are loading up mod_rewrite correctly! You should see something like LoadModule rewrite_module libexec/httpd/mod_rewrite.so and AddModule mod_rewrite.c in your httpd.conf." I'm using XAMPP on linux. I've found my httpd.conf file in opt/lampp/ etc, but am not sure what I need to do with it. I've searched for "rewrite", and there's only one line: LoadModule rewrite_module modules/mod_rewrite.so There's nothing about AddModule mod_rewrite.c. Do I just create a Directory section for the directory I've installed Cake in and set AlllowOverride to All? (I created a separate subdirectory of my wwwroot and installed in there, since I also have installs of Joomla and CodeIgniter.) Is there anything else I need to do? My download of Cake did come with two htaccess-type files (._.htaccess and .htaccess) - do I need to do anything with them? Thanks for any help you can provide to this non-server-admin. EDIT TO ADD virtual host sample: <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot /www/docs/dummy-host.example.com ServerName dummy-host.example.com ServerAlias www.dummy-host.example.com ErrorLog logs/dummy-host.example.com-error_log CustomLog logs/dummy-host.example.com-access_log common </VirtualHost>

    Read the article

  • JavaScript: Can I declare a variable by querying which function is called? (Newbie)

    - by belle3WA
    I'm working with an existing JavaScript-powered cart module that I am trying to modify. I do not know JS and for various reasons need to work with what is already in place. The text that appears for my quantity box is defined within an existing function: function writeitems() { var i; for (i=0; i<items.length; i++) { var item=items[i]; var placeholder=document.getElementById("itembuttons" + i); var s="<p>"; // options, if any if (item.options) { s=s+"<select id='options"+i+"'>"; var j; for (j=0; j<item.options.length; j++) { s=s+"<option value='"+item.options[j].name+"'>"+item.options[j].name+"</option>"; } s=s+"</select>&nbsp;&nbsp;&nbsp;"; } // add to cart s=s+method+"Quantity: <input id='quantity"+i+"' value='1' size='3'/> "; s=s+"<input type='submit' value='Add to Cart' onclick='addtocart("+i+"); return false;'/></p>"; } placeholder.innerHTML=s; } refreshcart(false); } I have two different types of quantity input boxes; one (donations) needs to be prefaced with a dollar sign, and one (items) should be blank. I've taken the existing additem function, copied it, and renamed it so that there are two identical functions, one for items and one for donations. The additem function is below: function additem(name,cost,quantityincrement) { if (!quantityincrement) quantityincrement=1; var index=items.length; items[index]=new Object; items[index].name=name; items[index].cost=cost; items[index].quantityincrement=quantityincrement; document.write("<span id='itembuttons" + index + "'></span>"); return index; } Is there a way to declare a global variable based on which function (additem or adddonation) is called so that I can add that into the writeitems function so display or hide the dollar sign as needed? Or is there a better solution? I can't use HTML in the body of the cart page because of the way it is currently coded, so I'm depending on the JS to take care of it. Any help for a newbie is welcome. Thanks!

    Read the article

  • Invalid function declaration. DevC++

    - by user69514
    Why do I get invalid function declaration when I compile the code in DevC++ in Windows, but when I compile it in CodeBlocks on Linux it works fine. #include <iostream> #include <vector> using namespace std; //structure to hold item information struct item{ string name; double price; }; //define sandwich, chips, and drink struct item sandwich{"Sandwich", 3.00}; **** error is here ***** struct item chips{"Chips", 1.50}; **** error is here ***** struct item drink{"Large Drink", 2.00}; **** error is here ***** vector<item> cart; //vector to hold the items double total = 0.0; //total const double tax = 0.0825; //tax //gets item choice from user char getChoice(){ cout << "Select an item:" << endl; cout << "S: Sandwich. $3.00" << endl; cout << "C: Chips. $1.50" << endl; cout << "D: Drink. $2.00" << endl; cout << "X: Cancel. Start over" << endl; cout << "T: Total" << endl; char choice; cin >> choice; return choice; } //displays current items in cart and total void displayCart(){ cout << "\nCart:" << endl; for(unsigned int i=0; i<cart.size(); i++){ cout << cart.at(i).name << ". $" << cart.at(i).price << endl; } cout << "Total: $" << total << endl << endl; } //adds item to the cart void addItem(struct item bought){ cart.push_back(bought); total += bought.price; displayCart(); } //displays the receipt, items, prices, subtotal, taxes, and total void displayReceipt(){ cout << "\nReceipt:" << endl; cout << "Items: " << cart.size() << endl; for(unsigned int i=0; i<cart.size(); i++){ cout << (i+1) << ". " << cart.at(i).name << ". $" << cart.at(i).price << endl; } cout << "----------------------------" << endl; cout << "Subtotal: $" << total << endl; double taxes = total*tax; cout << "Tax: $" << taxes << endl; cout << "Total: $" << (total + taxes) << endl; } int main(){ //sentinel to stop the loop bool stop = false; char choice; while (stop == false ){ choice = getChoice(); //add sandwich if( choice == 's' || choice == 'S' ){ addItem(sandwich); } //add chips else if( choice == 'c' || choice == 'C' ){ addItem(chips); } //add drink else if( choice == 'd' || choice == 'D' ){ addItem(drink); } //remove everything from cart else if( choice == 'x' || choice == 'X' ){ cart.clear(); total = 0.0; cout << "\n***** Transcation Canceled *****\n" << endl; } //calcualte total else if( choice == 't' || choice == 'T' ){ displayReceipt(); stop = true; } //or wront item picked else{ cout << choice << " is not a valid choice. Try again\n" << endl; } }//end while loop return 0; //end of program }

    Read the article

  • Is it possible to use jquery to add numbers taken from mysql?

    - by Scarface
    Hey guys quick question. I have a div that gets assigned a number to its id that is taken from the database on page load. I am trying to use jquery to add 1 to that number but for example if the number was 70 to begin with it just becomes 701. Anyone know what I am doing wrong? echo "<div class=\"total\" id=\"$total\">$total</div>"; var total=$(".total").attr("id"); var newtotal=total+1; $('.total').html(newtotal);

    Read the article

  • improve my python program to fetch the desire rows by using if condition

    - by user2560507
    unique.txt file contains: 2 columns with columns separated by tab. total.txt file contains: 3 columns each column separated by tab. I take each row from unique.txt file and find that in total.txt file. If present then extract entire row from total.txt and save it in new output file. ###Total.txt column a column b column c interaction1 mitochondria_205000_225000 mitochondria_195000_215000 interaction2 mitochondria_345000_365000 mitochondria_335000_355000 interaction3 mitochondria_345000_365000 mitochondria_5000_25000 interaction4 chloroplast_115000_128207 chloroplast_35000_55000 interaction5 chloroplast_115000_128207 chloroplast_15000_35000 interaction15 2_10515000_10535000 2_10505000_10525000 ###Unique.txt column a column b mitochondria_205000_225000 mitochondria_195000_215000 mitochondria_345000_365000 mitochondria_335000_355000 mitochondria_345000_365000 mitochondria_5000_25000 chloroplast_115000_128207 chloroplast_35000_55000 chloroplast_115000_128207 chloroplast_15000_35000 mitochondria_185000_205000 mitochondria_25000_45000 2_16595000_16615000 2_16585000_16605000 4_2785000_2805000 4_2775000_2795000 4_11395000_11415000 4_11385000_11405000 4_2875000_2895000 4_2865000_2885000 4_13745000_13765000 4_13735000_13755000 My program: file=open('total.txt') file2 = open('unique.txt') all_content=file.readlines() all_content2=file2.readlines() store_id_lines = [] ff = open('match.dat', 'w') for i in range(len(all_content)): line=all_content[i].split('\t') seq=line[1]+'\t'+line[2] for j in range(len(all_content2)): if all_content2[j]==seq: ff.write(seq) break Problem: but istide of giving desire output (values of those 1st column that fulfile the if condition). i nead somthing like if jth of unique.txt == ith of total.txt then write ith row of total.txt into new file.

    Read the article

  • C - Call a function

    - by Pedro
    Hello. I want to get a value from a function in other function i think i have to call a function in other function, then call it on main, but how? void funcA(PEOPLE people[], int *total){ FILE *fp; char line[100]; fp=fopen("example.txt","r"); if(fp==NULL){ exit(1); } else{ fgets(line, 100, fp);//get a number from the txt total=atoi(linha);//convert to int } } void funcB(PEOPLE people[], int *total){ int i; for(i=0;i<total;i++){ printf("%s\n",people[i].name); } funcA(people,&total); } void main(){ PERSON person[100]; int *total; funcB(people,&total); } What i'm doing wrong?

    Read the article

  • Remove Class on input cheched not working

    - by Manna
    I have set that if the Input checkbox is checked the opacity turn from 0.5 to 1. It'not working, it actually works if i do the opposite, but this is not my goal! My CSS code .opacitychange {opacity: 1;} #total {opacity: 0.5} and if($("#iva").is(':checked')) { $('#total').html('+' + vat); total += vat; $('#total').addClass("opacitychange"); } else $('#total').html('0.00').removeClass("opacitychange"); if($("#irpef").is(':checked')) { $('#total1').html('-' + irpf); total -= irpf; $('#total1').addClass("opacitychange"); } else $('#total1').html('0.00').removeClass("opacitychange"); $("#total2").html(total.toFixed(2)); }; What's wrong? Here the case

    Read the article

  • Where to declare variable? C#

    - by user1303781
    I am trying to make an average function... 'Total' adds them, then 'Total' is divided by n, the number of entries... No matter where I put 'double Total;', I get an error message. In this example I get... Use of unassigned local variable 'Total' If I put it before the comment, both references show up as error... I'm sure it's something simple..... namespace frmAssignment3 { class StatisticalFunctions { public static class Statistics { //public static double Average(List<MachineData.MachineRecord> argMachineDataList) public static double Average(List<double> argMachineDataList) { double Total; int n; for (n = 1; n <= argMachineDataList.Count; n++) { Total = argMachineDataList[n]; } return Total / n; } public static double StDevSample(List<MachineData.MachineRecord> argMachineDataList) { return -1; } } } }

    Read the article

  • wp e-commerce php modification

    - by user1015687
    Here are a few lines of code from a wordpress plugin (WP E-commerce) that calculate the price. Now what i want is that if 'cart_item' are more than 3 in quantity then the price should be (number of items * 4) else the function should work as it is listed below. Thnks for help. function calculate_subtotal($for_shipping = false) { 1047 global $wpdb; 1048 if($for_shipping == true ) { 1049 $total = 0; 1050 foreach($this->cart_items as $key => $cart_item) { 1051 if($cart_item->uses_shipping == 1) { 1052 $total += $cart_item->total_price; 1053 } 1054 } 1055 } else { 1056 $total = 0; 1057 if($this->subtotal == null) { 1058 foreach($this->cart_items as $key => $cart_item) { 1059 $total += $cart_item->total_price; 1060 } 1061 $this->subtotal = $total; 1062 } else { 1063 $total = $this->subtotal; 1064 } 1065 } 1066 return $total; 1067 }

    Read the article

  • FAQ: GridView Calculation with JavaScript

    - by Vincent Maverick Durano
    In my previous post I wrote a simple demo on how to Calculate Totals in GridView and Display it in the Footer. Basically what it does is it calculates the total amount by typing into the TextBox and display the grand total in the footer of the GridView and basically it was a server side implemenation.  Many users in the forums are asking how to do the same thing without postbacks and how to calculate both amount and total amount together. In this post I will demonstrate how to do this using JavaScript. To get started let's go ahead and set up the form. Just for the simplicity of this demo I just set up the form like this:   <asp:gridview ID="GridView1" runat="server" ShowFooter="true" AutoGenerateColumns="false"> <Columns> <asp:BoundField DataField="RowNumber" HeaderText="Row Number" /> <asp:BoundField DataField="Description" HeaderText="Item Description" /> <asp:TemplateField HeaderText="Item Price"> <ItemTemplate> <asp:Label ID="LBLPrice" runat="server" Text='<%# Eval("Price") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Quantity"> <ItemTemplate> <asp:TextBox ID="TXTQty" runat="server"></asp:TextBox> </ItemTemplate> <FooterTemplate> <b>Total Amount:</b> </FooterTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Sub-Total"> <ItemTemplate> <asp:Label ID="LBLSubTotal" runat="server"></asp:Label> </ItemTemplate> <FooterTemplate> <asp:Label ID="LBLTotal" runat="server" ForeColor="Green"></asp:Label> </FooterTemplate> </asp:TemplateField> </Columns> </asp:gridview>   As you can see there's no fancy about the mark up above. It just a standard GridView with BoundFields and TemplateFields on it. Now just for the purpose of this demo I just use a dummy data for populating the GridView. Here's the code below:   public partial class GridCalculation : System.Web.UI.Page { private void BindDummyDataToGrid() { DataTable dt = new DataTable(); DataRow dr = null; dt.Columns.Add(new DataColumn("RowNumber", typeof(string))); dt.Columns.Add(new DataColumn("Description", typeof(string))); dt.Columns.Add(new DataColumn("Price", typeof(string))); dr = dt.NewRow(); dr["RowNumber"] = 1; dr["Description"] = "Nike"; dr["Price"] = "1000"; dt.Rows.Add(dr); dr = dt.NewRow(); dr["RowNumber"] = 2; dr["Description"] = "Converse"; dr["Price"] = "800"; dt.Rows.Add(dr); dr = dt.NewRow(); dr["RowNumber"] = 3; dr["Description"] = "Adidas"; dr["Price"] = "500"; dt.Rows.Add(dr); dr = dt.NewRow(); dr["RowNumber"] = 4; dr["Description"] = "Reebok"; dr["Price"] = "750"; dt.Rows.Add(dr); dr = dt.NewRow(); dr["RowNumber"] = 5; dr["Description"] = "Vans"; dr["Price"] = "1100"; dt.Rows.Add(dr); dr = dt.NewRow(); dr["RowNumber"] = 6; dr["Description"] = "Fila"; dr["Price"] = "200"; dt.Rows.Add(dr); //Bind the Gridview GridView1.DataSource = dt; GridView1.DataBind(); } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindDummyDataToGrid(); } } }   Now try to run the page. The output should look something like below: The Client-Side Calculation Here's the code for the GridView calculation:   <script type="text/javascript"> function CalculateTotals() { var gv = document.getElementById("<%= GridView1.ClientID %>"); var tb = gv.getElementsByTagName("input"); var lb = gv.getElementsByTagName("span"); var sub = 0; var total = 0; var indexQ = 1; var indexP = 0; for (var i = 0; i < tb.length; i++) { if (tb[i].type == "text") { sub = parseFloat(lb[indexP].innerHTML) * parseFloat(tb[i].value); if (isNaN(sub)) { lb[i + indexQ].innerHTML = ""; sub = 0; } else { lb[i + indexQ].innerHTML = sub; } indexQ++; indexP = indexP + 2; total += parseFloat(sub); } } lb[lb.length -1].innerHTML = total; } </script>   The code above calculates the sub-total by multiplying the price and the quantity and at the same time calculates the total amount  by adding the sub-total values. Now you can simply call the JavaScript function above like this:   <ItemTemplate> <asp:TextBox ID="TXTQty" runat="server" onkeyup="CalculateTotals();"></asp:TextBox> </ItemTemplate>   Running the code above will display something like below: That's it! I hope someone find this post useful! Technorati Tags: ASP.NET,JavaScript,GridView,TipsTricks

    Read the article

  • OS Development. Only Few Particular Questions

    - by Total Anime Immersion
    I am new to this site as a member but have consulted its answers quite a lot of times. Besides my questions regarding OS Development hasn't been answered in any forum. In OS Dev. we make a bootloader. The org point is 7C00H. Why so? Why not 0000h? What are the last two signatures in the bootloader used for? People on every forum have answered that it is important for the system to recognize it as a bootable media. But I want a specific answer. What do each of those signatures do. I have the basic concept of a kernel. Point is.. it relates to different files required in a system. It sort of binds up everything that is individually developed. Now the thing is that that I have floating ideas in my mind regarding different aspects like keyboard, mouse, etc.. how do I put them all together? Which should I start with first? If possible please provide a step by step procedure of the startups of the kernel. Suppose I have developed my language entirely in C and Assembly. Now questions is will exe files work on my system.. if it doesn't then I have to create my own files and publish them. Which is a bad idea.. next step would be for me to go for a compiler for a language which I have designed myself. Now the point is.. How do I implement the compiler into my OS? After all this my final question is that.. How do you go about multitasking and multithreading? and I don't want to use int 21h as its dos specific.. how do I go about making files, renaming them, etc. and all assembly books teach 16 but programming.. how do i go about doing 32 bit or 64 bit with the knowledge I have.. if the basics and instructions are the same.. I don't mind.. but how do i go about otherwise? Don't tell me to give up the idea because I WON'T. And don't tell me it's too complex because I have a sharp knowledge of working of a system, C, Java, Assembly, C++ and python, C#, visual basic.. and not just basics but full fledged api developments.. but I really want to go deep into the systems part.. so I want professional help.. And I have gone through many OS project files but I want help particularly from this site as there are people with knowledge depth who can guide me the right way. And please don't suggest any books above 20$ and they should be available on flipkart as amazon charges massively for shipping and I prefer free shipping from flipkart.

    Read the article

< Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >