Daily Archives

Articles indexed Saturday April 24 2010

Page 4/78 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Jqyery Bugs?? Long decimal number after two numbers multiply...

    - by Jerry
    Hi all I am working on a shopping site and I am trying to calculate the subtotal of products. I got my price from a array and quantity from getJSON response array. Two of them multiply comes to my subtotal. I can change the quantity and it will comes out different subtotal. However,when I change the quantity to certain number, the final subtotal is like 259.99999999994 or some long decimal number. I use console.log to check the $price and $qty. Both of them are in the correct format ex..299.99 and 6 quantity.I have no idea what happen. I would appreciate it if someone can help me about it. Here is my Jquery code. $(".price").each(function(index, price){ $price=$(this); //get the product id and the price shown on the page var id=$price.closest('tr').attr('id'); var indiPrice=$($price).html(); //take off $ indiPrice=indiPrice.substring(1) //make sure it is number format var aindiPrice=Number(indiPrice); //push into the array productIdPrice[id]=(aindiPrice); var url=update.php $.getJSON( url, {productId:tableId, //tableId is from the other jquery code which refers to qty:qty}, productId function(responseProduct){ $.each(responseProduct, function(productIndex, Qty){ //loop the return data if(productIdPrice[productIndex]){ //get the price from the previous array we create X Qty newSub=productIdPrice[productIndex]*Number(Qty); //productIdPrice[productIndex] are the price like 199.99 or 99.99 // Qty are Quantity like 9 or 10 or 3 sum+=newSub; newSub.toFixed(2); //try to solve the problem with toFixed but didn't work console.log("id: "+productIdPrice[productIndex]) console.log("Qty: "+Qty); console.log(newSub); **//newSub sometime become XXXX.96999999994** }; Thanks again!

    Read the article

  • decompress .gz file in batch

    - by kapildalwani
    I have 100 of .gz files which I need to de-compress. I have couple of questions a) I am using the code given at http://www.roseindia.net/java/beginners/JavaUncompress.shtml to decompress the .gz file. Its working fine. Quest:- is there a way to get the file name of the zipped file. I know that Zip class of Java gives of enumeration of entery file to work upon. This can give me the filename, size etc stored in .zip file. But, do we have the same for .gz files or does the file name is same as filename.gz with .gz removed. b) is there another elegant way to decompress .gz file by calling the utility function in the java code. Like calling 7-zip application from your java class. Then, I don't have to worry about input/output stream. Thanks in advance. Kapil

    Read the article

  • commons-exec: hanging when I call executor.execute(commandLine);

    - by Stefan Kendall
    I have no idea why this is hanging. I'm trying to capture output from a process run through commons-exec, and I continue to hang. I've provided an example program to demonstrate this behavior below. import java.io.DataInputStream; import java.io.IOException; import java.io.PipedInputStream; import java.io.PipedOutputStream; import org.apache.commons.exec.CommandLine; import org.apache.commons.exec.DefaultExecutor; import org.apache.commons.exec.ExecuteException; import org.apache.commons.exec.PumpStreamHandler; public class test { public static void main(String[] args) { String command = "java"; PipedOutputStream output = new PipedOutputStream(); PumpStreamHandler psh = new PumpStreamHandler(output); CommandLine cl = CommandLine.parse(command); DefaultExecutor exec = new DefaultExecutor(); DataInputStream is = null; try { is = new DataInputStream(new PipedInputStream(output)); exec.setStreamHandler(psh); exec.execute(cl); } catch (ExecuteException ex) { } catch (IOException ex) { } System.out.println("huh?"); } }

    Read the article

  • Does Mootools prevents javascript closure 100%?

    - by terrani
    Hi, While I was talking about javascript closure to my friend, I was told that using Mootools can prevent closures 100%. To my knowledege, a variable causes a closure. How does Mootools itself prevents javascript closure? I think my friend is sayting that Mootools' functions are closure-safe functions. Any suggestions?

    Read the article

  • How to play sound from libray in AS3?

    - by Ullallulloo
    In Flash 10/AS3, I added some sound and it seems to be working alright, but I think I'm doing it wrong. I imported the sound into the library, but I believe that it's reloading it from the folder with the swf/sound. I'm loading them like so: var request1:URLRequest = new URLRequest("CLICK8C.mp3"); clickSound = new Sound(); clickSound.addEventListener(Event.COMPLETE, completeHandler); clickSound.load(request1); Is there a way to get it to just load it from the library?

    Read the article

  • Prevent lock of windows detecting user idle time

    - by Zimelemon
    I work in a Windows Terminal Server enviroment where if you left the computer for a while, windows lock the session and terminal is power off. What i need is the code needed to send a message to Windows for it to believe the user is in front of the PC (mouse or keyboard activity). Thanks in advance

    Read the article

  • Setting Mercurial's execute bit on Windows

    - by Joe
    I work on a Mercurial repository that is checked out onto an Unix filesystem such as ext3 on some machines, and FAT32 on others. In Subversion, I can set the svn:executable property to control whether a file should be marked executable when checked out on a platform that supports such a bit. I can do this regardless of the platform I'm running SVN on or the filesystem containing my working copy. In Mercurial, I can chmod +x to get the same effect if the clone is on a Unix filesystem. But how can I set (or remove) the executable bit on a file on a FAT filesystem?

    Read the article

  • SQL SERVER – T-SQL Script to Take Database Offline – Take Database Online

    - by pinaldave
    Blog reader Joyesh Mitra recently left a comment to one of my very old posts about SQL SERVER – 2005 Take Off Line or Detach Database, which I have written focusing on taking the database offline. However, I did not include how to bring the offline database to online in that post. The reason I did not write it was that I was thinking it was a very simple script that almost everyone knows. However, it seems to me that there is something I found advanced in this procedure that is not simple for other people. We all have different expertise and we all try to learn new things, so I do not see any reason as to not write about the script to take the database online. -- Create Test DB CREATE DATABASE [myDB] GO -- Take the Database Offline ALTER DATABASE [myDB] SET OFFLINE WITH ROLLBACK IMMEDIATE GO -- Take the Database Online ALTER DATABASE [myDB] SET ONLINE GO -- Clean up DROP DATABASE [myDB] GO Joyesh let me know if this answers your question. Reference : Pinal Dave (http://blog.SQLAuthority.com) Filed under: Pinal Dave, Readers Question, SQL, SQL Authority, SQL Query, SQL Scripts, SQL Server, SQL Tips and Tricks, SQLServer, T SQL, Technology

    Read the article

  • Initializing PHP class property declarations with simple expressions yields syntax error

    - by user171929
    According to the PHP docs, one can initialize properties in classes with the following restriction: "This declaration may include an initialization, but this initialization must be a constant value--that is, it must be able to be evaluated at compile time and must not depend on run-time information in order to be evaluated." I'm trying to initialize an array and having some issues. While this works fine: public $var = array( 1 => 4, 2 => 5, ); This creates a syntax error: public $var = array( 1 => 4, 2 => (4+1), ); Even this isn't accepted: public $var = 4+1; which suggests it's not a limitation of the array() language construct. Now, the last time I checked, "4+1" equated to a constant value that not only should be accepted, but should in fact be optimized away. In any case, it's certainly able to be evaluated at compile-time. So what's going on here? Is the limitation really along the lines of "cannot be any calculated expression at all", versus any expression "able to be evaluated at compile time"? The use of "evaluated" in the doc's language suggests that simple calculations are permitted, but alas.... If this is a bug in PHP, does anyone have a bug ID? I tried to find one but didn't have any luck.

    Read the article

  • jquery - check length of input field?

    - by KnockKnockWhosThere
    The code below is intended to enable the submit button once the user clicks in the textarea field. It works, but I'm trying to also make it so that it's only enabled if there's at least one character in the field. I tried wrapping it in: if($(this).val().length > 1) { } But, that didn't seem to work... Any ideas? $("#fbss").focus(function(){ $(this).select(); if($(this).val()=="Default text") { $(this).val(""); $("input[id=fbss-submit]").removeClass(); $("input[id=fbss-submit]").attr('disabled',false); $("input[id= fbss-submit]").attr('class','.enableSubmit'); if($('.charsRemaining')) { $('.charsRemaining').remove(); $("textarea[id=fbss]").maxlength({ maxCharacters: 190, status: true, statusClass: 'charsRemaining', statusText: 'characters left', notificationClass: 'notification', showAlert: false, alertText: 'You have exceeded the maximum amount of characters', slider: false }); } });

    Read the article

  • Converting from Mercurial to Subversion

    - by Matt Joiner
    Due to lack of Mercurial support in several tools, and managerial oppression it has become necessary to convert several trial Mercurial repositories to Subversion in order to conform with the company standard. Are there any tools or suggestions for how to achieve this without a loss of revision history and the like?

    Read the article

  • SQL Get Latest Unique Rows

    - by Simpleton
    I have a log table, each row representing an object logging its state. Each object has a unique, unchanging GUID. There are multiple objects logging their states, so there will be thousands of entries, with objects continually inserting new logs. Everytime an object checks in, it is via an INSERT. I have the PrimaryKey, GUID, ObjectState, and LogDate columns in tblObjects. I want to select the latest (by datetime) log entry for each unique GUID from tblObjects, in effect a 'snapshot' of all the objects. How can this be accomplished?

    Read the article

  • get entire line with java.util.scanner.hasNext(regex)

    - by Hussain
    I'm doing something in Java that requires input to be matched against the pattern ^[1-5]$. I should have a while loop looping through each line of input, checking it against the pattern, and outputting an error message if it does not. Sudo code: while (regex_match(/^[^1-5]$/,inputLine)) { print ("Please enter a number between 1 and 5! "); getNextInputLine(); } I can use java.util.Scanner.hasMatch("^[^1-5]$"), but that will only match a single token, not the entire line. Any idea on how to make hasMatch match against the entire line? (Setting the delimiter to "\n" or "\0" doesn't work.)

    Read the article

  • How to not run function if its a mobile device?

    - by Deshiknaves
    I have a modal pop up function on my website, but i don't want this to run if the browser is smaller than 480px. I have found that if I put an if statement such as: if (window.innerWidth && window.innerWidth > 480) { run function() } Then it should run only if the browsers innerWidth is 480. However its not working and I think its because I have page scaling on this website. Can any one help me with a conditional statement if page scaling is on? Thanks.

    Read the article

  • Is it possible to change the border color of a UISearchDisplayController's search bar?

    - by prendio2
    I have a UISearchBar added as my table header with the following code. searchBar = [[UISearchBar alloc] initWithFrame:self.tableView.bounds]; searchBar.tintColor = [UIColor colorWithWhite:185.0/255 alpha:1.0]; [searchBar sizeToFit]; self.tableView.tableHeaderView = searchBar; Then I set my UISearchDisplayController up as follows. searchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self]; [searchDisplayController setDelegate:self]; [searchDisplayController setSearchResultsDataSource:self]; Everything functions as I would like except that the UISearchDisplayController has added a blue(ish) border above the search bar — this bar does not recognise the tintColor I have set on the search bar. Is it possible to change the color of this bar? It is obviously not absolutely crucial but that line is going to bug me forever if it stays blue like that!

    Read the article

  • winform - login form template

    - by BhejaFry
    Hi folks, new to winform development. I am trying to add a 'login form' to my project in vs2008 but the template is missing. When i do 'add new item', i don't see 'login form'. However i do see mainform, aboutbox form templates. TIA

    Read the article

  • C#: Windows Forms: Getting keystrokes in a panel/picturebox?

    - by Rosarch
    I'm making a level editor for a game using windows forms. The form has several drop down menus, text boxes, etc, where the user can type information. I want to make commands like CTRL + V or CTRL + A available for working within the game world itself, not text manipulation. The game world is represented by a PictureBox contained in a Panel. This event handler isn't ever firing: private System.Windows.Forms.Panel canvas; // ... this.canvas = new System.Windows.Forms.Panel(); // ... this.canvas.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.canvas_PreviewKeyDown); What is the preferred way of doing this? Can a panel even receive keyboard input? I would like to allow the user to use copy/paste/select-all commands when working with the text input, but not when placing objects in the game world.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >