Search Results

Search found 1817 results on 73 pages for 'corina 123'.

Page 56/73 | < Previous Page | 52 53 54 55 56 57 58 59 60 61 62 63  | Next Page >

  • How to load data on option box in php

    - by user225269
    I'm having trouble loading the mysql data on the html form option box using php. Here's my code: <?php $con = mysql_connect("localhost","myuname","mypassword"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("school", $con); $idnum= mysql_real_escape_string($_POST['idnum']); $result = mysql_query("SELECT * FROM student WHERE IDNO='$idnum'"); ?> <?php while ( $row = mysql_fetch_array($result) ) { ?> <tr> <td width="30" height="35"><font size="2">*I D Number:</td> <td width="30"><input name="idnum" type="text" maxlength="5" value="<?php echo $row["IDNO"]; ?>" readonly="readonly"></td> </tr> My problem is loading it here: <td><font size="2">Gender</td> <td> <select name="gender" id="gender"> <font size="2"> <option value="<?php echo $line['IDNO']; ?> "><?php $line['GENDER'] ; ?></option> </select></td></td> The table looks like this: IDNO | GENDER 123 | M 321 | F What am I supposed to do?To load the exact gender corresponding to the IDNO?

    Read the article

  • Connection string problems on shared hosting with sql server 2005 express

    - by dagogo
    hi i have problem connecting to my db on a shared hosting, my host provider says they deployed sql 2005 express on their database and i prepared my connection string as follows to take advantage of sql express. \ the data source nae i used originally was ./SQLExpress but my host provider asked that i change it to local host, although with the former it didnt connect, but still with the change as indicated above the error still comes up on access to my default page. the error is as follows; Server Error in '/' Application. Invalid value for key 'attachdbfilename'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: Invalid value for key 'attachdbfilename'. Source Error: Line 120: Public Function GetID(ByVal sLgaName As String) As Integer Line 121: Dim q As String = "Select PLID " & "From LGA " & "Where LGAName = " & "'" & sLgaName & "'" Line 122: Dim cn As New SqlConnection(Me.ConnectionString) Line 123: Dim cmd As New SqlCommand(q, cn) Line 124: ive read up a lot on the web and googled ma fingers numb on this, i have a deadline to deliver this project and having successfully built the app it frustrating for this to happen. pls help me.

    Read the article

  • Sorting CouchDB Views By Value

    - by Lee Theobald
    Hi all, I'm testing out CouchDB to see how it could handle logging some search results. What I'd like to do is produce a view where I can produce the top queries from the results. At the moment I have something like this: Example document portion { "query": "+dangerous +dogs", "hits": "123" } Map function (Not exactly what I need/want but it's good enough for testing) function(doc) { if (doc.query) { var split = doc.query.split(" "); for (var i in split) { emit(split[i], 1); } } } Reduce Function function (key, values, rereduce) { return sum(values); } Now this will get me results in a format where a query term is the key and the count for that term on the right, which is great. But I'd like it ordered by the value, not the key. From the sounds of it, this is not yet possible with CouchDB. So does anyone have any ideas of how I can get a view where I have an ordered version of the query terms & their related counts? I'm very new to CouchDB and I just can't think of how I'd write the functions needed.

    Read the article

  • PHP, MySQL, Memcache / Ajax Scaling Problem

    - by Jeff Andersen
    I'm building a ajax tic tac toe game in PHP/MySQL. The premise of the game is to be able to share a url like mygame.com/123 with your friends and you play multiple simultaneous games. The way I have it set up is that a file (reload.php) is being called every 3 seconds while the user is viewing their game board space. This reload.php builds their game boards and the output (html) replaces their current game board (thus showing games in which it is their turn) Initially I built it entirely with PHP/MySQL and had zero caching. A friend gave me a suggestion to try doing all of the temporary/quick read information through memcache (storing moves, and ID matchups) and then building the game boards from this information. My issue is that, both solutions encounter a wall when there is roughly 30-40 active users with roughly 40-50 games running. It is running on a VPS from VPS.net with 2 nodes. (Dedicated CPU: 1.2GHz, RAM: 752MB) Each call to reload.php peforms 3 selects and 2 insert queries. The size of the data being pulled is negligible. The same actions happen on index.php to build the boards for the initial visit. Now that the backstory is done, my question is: Would there be a bottleneck in that each user is polling the same file every 3 seconds to rebuild their gameboards, and that all users are sitting on index.php from which the AJAX calls are made within the HTML. If so, is it possible to spread the users' calls out over a set of files designated to building the game boards (eg. reload1.php 2, 3 etc) and direct users to the appropriate file. Would this relieve the pressure? A long winded explanation; however, I didn't have anywhere else to ask. Thanks very much for any insight.

    Read the article

  • C++ Conceptual problem with (Pointer) Pointers

    - by Ptr
    I have a structure usually containing a pointer to an int. However, in some special cases, it is necessary that this int pointer points to another pointer which then points to an int. Wow: I mentioned the word pointer 5 times so far! Is this even possible? I thought about it that way: Instead of using a second int pointer, which is most likely not possible as my main int pointer can only point to an int and not to another int pointer, I could make it a reference like this: int intA = 1; int intB = 2; int& intC = intB; int* myPointers[ 123 ]; myPointers[ 0 ] = &intA; myPointers[ 1 ] = &intB; myPointers[ 3 ] = &intC; So the above would do what I want: The reference to intB (intC) behaves quite like I want it to (If it gets changed it also changes intB) The problem: I can't change references once they are set, right? Or is there a way? Everything in short: How do I get a value to work with * (pointers) and ** (pointers to pointers)?

    Read the article

  • AttributeError in my Python program regarding classes

    - by Axel Finkel
    I'm doing an exercise out of the Python book that involves creating a class and a subclass. I am getting the following error when I try to run the program: AttributeError: 'Customer' object has no attribute 'name', when it tries to go through this bit of code: self.name.append(name) As this is my first time dealing with classes and objects in Python, I'm sure I am making some overt mistake somewhere, but I can't seem to figure it out. I've looked over the documentation for creating classes and writing member functions, and it looks correct, but it is obviously not. I want the Customer subclass to inherit the name, address, and telephone attributes from the Person superclass, but it doesn't seem to be doing so? Here is my code: class Person: def __init__(self): self.name = None self.address = None self.telephone = None def changeName(self, name): self.name.append(name) def changeAddress(self, address): self.address.append(address) def changeTelephone(self, telephone): self.telephone.append(telephone) class Customer(Person): def __init__(self): self.customerNumber = None self.onMailingList = False def changeCustomerNumber(self, customerNumber): self.customerNumber.append(customerNumber) def changeOnMailingList(): if onMailingList == False: onMailingList == True else: onMailingList == False def main(): customer1 = Customer() name = 'Bob Smith' address = '123 Somewhere Road' telephone = '111 222 3333' customerNumber = '12345' customer1.changeName(name) customer1.changeAddress(address) customer1.changeTelephone(telephone) customer1.changeCustomerNumber(customerNumber) print("Customer name: " + customer1.name) print("Customer address: " + customer1.address) print("Customer telephone number: " + customer1.telephone) print("Customer number: " + customer1.customerNumber) print("On mailing list: " + customer1.OnMailingList) customer1.changeOnMailingList() print("On mailing list: " + customer1.OnMailingList) main()

    Read the article

  • how to print data in a table from mysql

    - by robertdd
    hello, i want to extract the last eight entries from my database and print them into a 2 columns table!like this: |1|2| |3|4| |5|6| |7|8| is that possible? this is my code: $db = new Database(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); $db->connect(); $sql = "SELECT ID, movieno FROM movies ORDER BY ID DESC LIMIT 8 "; $rows = $db->query($sql); print '<table width="307" border="0" cellspacing="5" cellpadding="4">'; while ($record = $db->fetch_array($rows)) { $vidaidi = $record['movieno']; print <<<END <tr> <td> <a href="http://www.youtube.com/watch?v=$vidaidi" target="_blank"> <img src="http://img.youtube.com/vi/$vidaidi/1.jpg" width="123" height="80"></a> </td> </tr> END; } print '</table>';

    Read the article

  • How to reset keyboard for an entry field?

    - by David.Chu.ca
    I am using tag field as a flag for text fields text view fields for auto-jumping to the next field: - (BOOL)findNextEntryFieldAsResponder:(UIControl *)field { BOOL retVal = NO; for (UIView* aView in mEntryFields) { if (aView.tag == (field.tag + 1)) { [aView becomeFirstResponder]; retVal = YES; break; } } return retVal; } It works fine in terms of auto-jumping to the next field when Next key is pressed. However, my case is that the keyboards are different some fields. For example, one fields is numeric & punctuation, and the next one is default (alphabetic keys). For the numeric & punctuation keyboard is OK, but the next field will stay as the same layout. It requires user to press 123 to go back ABC keyboard. I am not sure if there is any way to reset the keyboard for a field as its keyboard defined in xib? Not sure if there is any APIs available? I guess I have to do something is the following delegate? -(void)textFieldDidBegingEditing:(UITextField*) textField { // reset to the keyboard to request specific keyboard view? .... } OK. I found a solution close to my case by slatvik: -(void) textFieldDidBeginEditing:(UITextField*) textField { textField.keyboardType = UIKeybardTypeAlphabet; } However, in the case of the previous text fields is numeric, the keyboard stays numeric when auto-jumped to the next field. Is there any way to set keyboard to alphabet mode?

    Read the article

  • Rotate a linked list

    - by user408041
    I want to rotate a linked list that contains a number. 123 should be rotated to 231. The function created 23 but the last character stays empty, why? typedef struct node node; struct node{ char digit; node* p; }; void rotate(node** head){ node* walk= (*head); node* prev= (*head); char temp= walk->digit; while(walk->p!=NULL){ walk->digit=walk->p->digit; walk= walk->p; } walk->digit=temp; } How I create the list: node* convert_to_list(int num){ node * curr, * head; int i=0,length=0; char *arr=NULL; head = NULL; length =(int) log10(((double) num))+1; arr =(char*) malloc((length)*sizeof(char)); //allocate memory sprintf (arr, "%d" ,num); //(num, buf, 10); for(i=length;i>=0;i--) { curr = (node *)malloc(sizeof(node)); (curr)->digit = arr[i]; (curr)->p = head; head = curr; } curr = head; return curr; }

    Read the article

  • Set .aspx page title to that of an Eval

    - by user1860529
    I am trying to use an <%# Eval("name") %> to be the title of my page. I can't seem to figure out any solutions online. I have tried the other StackOverflow question but that did now work either. The page is a bio.aspx and on the site it is displayed as bio.aspx?id=123 so the page title needs to vary depending on the ID. I figured I could just use the Eval("name") but no luck yet. I currently am using JavaScript: window.onload = function() { document.title = '<%# Eval("name") %> | Title Line'; } This works, but it still leaves the title tags empty, and it's kind of spammy. Here is the codebehind: using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class DoctorBio : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Page.Title = "Your Page Title"; HtmlMeta metaDescription = new HtmlMeta(); metaDescription.Name = "description"; metaDescription.Content = "brief description"; Page.Header.Controls.Add(metaDescription); HtmlMeta metaKeywords = new HtmlMeta(); metaKeywords.Name = "keywords"; metaKeywords.Content = "keywords, keywords"; Page.Header.Controls.Add(metaKeywords); } protected void SetPageTitle(object title) { this.Title = title.ToString(); } protected string ReplaceLineBreaks(object text) { string newText = text as string; if (newText == null) { return string.Empty; } return newText.Replace("\r\n", "<br />"); } }

    Read the article

  • How to get the value of an XML element using Linq even when empty.

    - by Yeodave
    Please excuse my stupidity, I tend to find the traversing XML overly complicated. I am using ASP.NET in VB. I have an XML document which contains all the details of staff in my company... <staff> <staffName>Test Staff</staffName> <staffTitle>Slave</staffTitle> <staffDepartmentName>Finance</staffDepartmentName> <staffOffice>London</staffOffice> <staffEmail>[email protected]</staffEmail> <staffPhone>0207 123 456</staffPhone> <staffNotes>Working hours Mon to Thurs 9.15 - 5.15</staffNotes> <staffBio></staffBio> </staff> As you can see, some nodes do not always contain data for ever member of staff; only Directors have biographies. I access the values like this... For Each staff In ( _ From matches In myXMLFile.Descendants("staff").Descendants("staffName") _ Where matches.Nodes(0).ToString.ToLower.Contains(LCase(search)) _ Order By matches.Value _ Select matches) staffName = staff.Descendants("staffName").Nodes(0).ToString) staffTitle = staff.Descendants("staffTitle").Nodes(0).ToString) staffOffice = staff.Descendants("staffOffice").Nodes(0).ToString) staffEmail = staff.Descendants("staffEmail").Nodes(0).ToString) staffPhone = staff.Descendants("staffPhone").Nodes(0).ToString) staffNotes = staff.Descendants("staffNotes").Nodes(0).ToString) staffBio = staff.Descendants("staffBio").Nodes(0).ToString) ' Do something with that data... Next Once it gets to staffBio I get an error saying "Object reference not set to an instance of an object." obviously because that node does not exist. My question is how can I assign the value to a variable even when it is empty without having to do a conditional check before each assignment?

    Read the article

  • implementing interface

    - by 1ace1
    hello guys so i have this assignment that i need to implement interface to go over an ArrayList and sort it (ascending or descnding).I dont want "the" answer i just need some suggestions on my approach and why i get this error Exception in thread "main" java.lang.ClassCastException: Week7.Check cannot be cast to java.lang.Comparable at java.util.Arrays.mergeSort(Unknown Source) at java.util.Arrays.sort(Unknown Source) at java.util.Collections.sort(Unknown Source) at Week7.TestCheck.main(TestCheck.java:18) This is how i did it: comparable had one method called public int compairTo(Object o) public class Check implements comparable { private Integer checkNumber; public Check(Integer newCheckNumber) { setCheckNumber(newCheckNumber); } public String toString() { return getCheckNumber().toString(); } public void setCheckNumber(Integer checkNumber) { this.checkNumber = checkNumber; } public Integer getCheckNumber() { return checkNumber; } @Override public int compairTo(Object o) { Check compair = (Check)o; int result = 0; if (this.getCheckNumber() > compair.getCheckNumber()) result = 1; else if(this.getCheckNumber() < compair.getCheckNumber()) result = -1; return result; } } in my main i had this import java.util.ArrayList; import java.util.Collections; public class TestCheck { public static void main(String[] args) { ArrayList checkList = new ArrayList(); checkList.add(new Check(445)); checkList.add(new Check(101)); checkList.add(new Check(110)); checkList.add(new Check(553)); checkList.add(new Check(123)); Collections.sort(checkList); for (int i =0; i < checkList.size(); i++){ System.out.println(checkList.get(i)); } } }

    Read the article

  • MySQL Query Where Column Like Column

    - by shmeeps
    I'm working on a small project that involves grabbing a list of contacts which are stored for each group. Essentially, the database is set up so that each group has a primary and secondary contact stored as, unsurprisingly, Group.Primary and Group.Secondary. The objective is to pull every Primary and Secondary contact for each Group and display them in a sortable table. I have the sortable table all worked out, but I have come across a small problem. Each primary and secondary field can have more than one contact separated by a comma. For instance, if Primary contained 123,256 , it would need to pull both Contacts with IDs 123 and 256. I had intended to use a query formatted like this: SELECT * FROM Group G, Contacts C WHERE G.Primary LIKE %C.ID% OR G.Secondary LIKE %C.ID% so that I could just skip the comma part, but I can't seem to find a working query for this. My question to you is, am I just overlooking something here? Is there a simple query that would let me do this? Or am I better off getting the groups and contacts separately, and combine the two later. I think the former is a little easier to understand when read, which is a plus as this is a shared project, but if that is not possible I will do the latter. This code is simplified, but it gets the point across.

    Read the article

  • Zimbra Problems

    - by Imax Satria
    I have a problem with my Zimbra Server, yahoo mail can't reply to my Zimbra Server, this the failure notice from yahoo : Sorry, we were unable to deliver your message to the following address. : No MX or A records for imaxsatria.25u.com --- Below this line is a copy of the message. Received: from [106.10.166.123] by nm17.bullet.mail.sg3.yahoo.com with NNFMP; 30 Aug 2012 00:06:07 -0000 Received: from [106.10.151.252] by tm12.bullet.mail.sg3.yahoo.com with NNFMP; 30 Aug 2012 00:06:07 -0000 Received: from [127.0.0.1] by omp1001.mail.sg3.yahoo.com with NNFMP; 30 Aug 2012 00:06:07 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: [email protected] Received: (qmail 46619 invoked by uid 60001); 30 Aug 2012 00:06:07 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1346285167; bh=JOd9hQyuDhBSxyuVvYQwIVOo6Dp7C1wsnvprDYxGUn8=; h=X-YMail-OSG:Received:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type; ................... Can you help me?

    Read the article

  • JavaScript array random index insertion and deletion

    - by Tomi
    I'm inserting some items into array with randomly created indexes, for example like this: var myArray = new Array(); myArray[123] = "foo"; myArray[456] = "bar"; myArray[789] = "baz"; ... In other words array indexes do not start with zero and there will be "numeric gaps" between them. My questions are: Will these numeric gaps be somehow allocated (and therefore take some memory) even when they do not have assigned values? When I delete myArray[456] from upper example, would items below this item be relocated? EDIT: Regarding my question/concern about relocation of items after insertion/deletion - I want to know what happens with the memory and not indexes. More information from wikipedia article: Linked lists have several advantages over dynamic arrays. Insertion of an element at a specific point of a list is a constant-time operation, whereas insertion in a dynamic array at random locations will require moving half of the elements on average, and all the elements in the worst case. While one can "delete" an element from an array in constant time by somehow marking its slot as "vacant", this causes fragmentation that impedes the performance of iteration.

    Read the article

  • Mechanize form submit not going to the correct response page, no errors as to why. Something I'm doing?

    - by Zack Shapiro
    I threw this all in one controller for testing purposes. My code fills out the form correctly for adding a new address to your Amazon account. There are two buttons that submit this form, one takes you to add a new address which is what I don't want, and the other is just a Save & Continue input/image. When I submit the form via that button, as I do below, the form is still on the page, filled out as I have with my code. Inspecting the page titles, they're the same. There are no discernible errors that Mechanize or Amazon spit back. Any ideas? class AmazonCrawler def initialize @agent = Mechanize.new do |agent| agent.user_agent_alias = 'Mac Safari' agent.follow_meta_refresh = true agent.redirect_ok = true end end def login # login_url = "https://www.amazon.com/ap/signin?_encoding=UTF8&openid.assoc_handle=usflex&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.pape.max_auth_age=0&openid.return_to=https%3A%2F%2Fwww.amazon.com%2Fgp%2Fcss%2Fhomepage.html%3Fie%3DUTF8%26ref_%3Dgno_yam_ya" login_url = "https://www.amazon.com/gp/css/account/address/view.html?ie=UTF8&ref_=ya_add_address&viewID=newAddress" @agent.get(login_url) form = @agent.page.forms.first form.email = "[email protected]" form.radiobuttons.first.value = "0" form.radiobuttons.last.check form.password = "my_password" dashboard = @agent.submit(form) end end class UsersController < ApplicationController def index response = AmazonCrawler.new.login form = response.forms[1] # fill out form form.enterAddressFullName == "Your Name" form.enterAddressAddressLine1 = "123 Main Street" form.enterAddressAddressLine2 = "Apartment 34" form.enterAddressCity = "San Francisco" form.enterAddressStateOrRegion = "CA" form.enterAddressPostalCode = "94101" form.enterAddressPhoneNumber = "415-555-1212" form.AddressType = "RES" new_response = form.submit( form.button_with(value: /Save.*Continue/) ) end end

    Read the article

  • Counting the number of occurrences of characters in an array

    - by Anthony Pittelli
    This is what I have but it is not working, this is confusing for me. If you scroll down I commented on someones post the exact problem I am having and what I am trying to do. I was thinking maybe the problem is my code to generate the random characters: public void add (char fromChar, char toChar){ Random r = new Random(); //creates a random object int randInt; for (int i=0; i<charArray.length; i++){ randInt = r.nextInt((toChar-fromChar) +1); charArray[i] = (char) randInt; //casts these integers as characters } }//end add public int[] countLetters() { int[] count = new int[26]; char current; for (int b = 0; b <= 26; b++) { for (int i = 97; i <= 123; i++) { char a = (char) i; for (int ch = 0; ch < charArray.length; ch++) { current = charArray[ch]; if (current == a) { count[b]++; } } } } return count; }

    Read the article

  • Memory fragmentation @ boost::asio ?

    - by Poni
    I'm pretty much stuck with a question I never got an answer for, a question which addresses an extremely important issue; memory fragmentation at boost::asio. Found nothing at the documentation nor here at SO. The functions at boost::asio, for example async_write() & async_read_some() always allocate something. (in my case it's 144 & 96 bytes respectively, in VC9 Debug build). How do I know about it? I connect a client to the "echo server" example provided with this library. I put a breakpoint at "new.cpp" at the code of "operator new(size_t size)". Then I send "123". Breakpoint is hit! Now using the stack trace I can clearly see that the root to the "new" call is coming from the async_write() & async_read_some() calls I make in the function handlers. So memory fragmentation will come sooner or later, thus I can't use ASIO, and I wish I could! Any idea? Any helpful code example?

    Read the article

  • Create 2nd tables and add data

    - by Tyler Matema
    I have this task from school, and I am confuse and lost on how I got to do this. So basically I have to create 2 tables to the database but I have to created from php. I have created the first table, but not the second one for some reason. And then, I have to populate first and second tables with 10 and 20 sample records respectively, populate, does it mean like adding more fake users? if so is it like the code shown below? *I got error on the populating second part as well Thank you so much for the help. <?php $host = "host"; $user = "me"; $pswd = "password"; $dbnm = "db"; $conn = @mysqli_connect($host, $user, $pswd, $dbnm); if (!$conn) die ("<p>Couldn't connect to the server!<p>"); $selectData = @mysqli_select_db ($conn, $dbnm); if(!$selectData) { die ("<p>Database Not Selected</p>"); } //1st table $sql = "CREATE TABLE IF NOT EXISTS `friends` ( `friend_id` INT NOT NULL auto_increment, `friend_email` VARCHAR(20) NOT NULL, `password` VARCHAR(20) NOT NULL, `profile_name` VARCHAR(30) NOT NULL, `date_started` DATE NOT NULL, `num_of_friends` INT unsigned, PRIMARY KEY (`friend_id`) )"; //2nd table $sqlMyfriends = "CREATE TABLE `myfriends` ( `friend_id1` INT NOT NULL, `friend_id2` INT NOT NULL, )"; $query_result1 = @mysqli_query($conn, $sql); $query_result2 = @mysqli_query($conn, $sqlMyfriends); //populating 1st table $sqlSt3="INSERT INTO friends (friend_id, friend_email, password, profile_name, date_started, num_of_friends) VALUES('NULL','[email protected]','123','abc','2012-10-25', 5)"; $queryResult3 = @mysqli_query($dbConnect,$sqlSt3) //populating 2nd table $sqlSt13="INSERT INTO myfriends VALUES(1,2)"; $queryResult13=@mysqli_query($dbConnect,$sqlSt13); mysqli_close($conn); ?>

    Read the article

  • Javascript Global Variable in Array

    - by user1387727
    My question may be very easy to lots of people, but I am new to Javascript. I really do not know what is wrong with the following codes. var newValue = 1; function getCurrentAmount() { return [newValue,2,3]; } var result = getCurrentAmount(); console.log(result[0] + "" + result[1] + result[2]); In the above code, the result shown in console is: undefined23 Why is the result not "123"? I am trying to use global variable because I want to increment newValue by 1 each time when the function is called. I want something like the following: var newValue = 1; function getCurrentAmount() { newValue ++; return [newValue,2,3]; } setInterval(function(){ var result = getCurrentAmount(); console.log(result[0] + "" + result[1] + result[2]); }, 1000); Also, I just tired the following codes and it works as expected. var newValue =1; function test() { newValue ++; return newValue; } console.log(test()); So I think the problem is about the Array. I hope my question is clear enough. Thanks in advance.

    Read the article

  • How to get two TD cells side by side WITHOUT using css

    - by Joe
    Hi, in the following HTML snippet, I would like the two cells be placed side by side with NO spaces between them; without using css if possible. If the leftmost position of the 2nd one is the rightmost position of the 1st, why WOULD they have any space between? thx. <TR> <TD style="position:absolute; top:98px; left:0px; right:56px; bottom:126px; font-size: 7pt; background-color:Lime; text-align: center; font-family: Arial;" cellpadding="0" cellspacing="0">ABC</TD> <TD style="position:absolute; top:98px; left:56px; right:112px; bottom:126px; font-size: 7pt; background-color:Lime; text-align: center; font-family: Arial;" cellpadding="0" cellspacing="0">123</TD>

    Read the article

  • How do I parse data received in a memorystream?

    - by Kerberos42
    I'm new to using sockets. I have a very basic client that sends a request, and waits for a response. The response is one stream, but has two parts. The first part is prefixed with ANS and is a set of key/value pairs in this form: KEY:Value with each pair on a separate line. The second part of the response is prefixed by RCT and this is pre-formatted text that needs to be send directly to a printer. So what would be the best way to extract both parts of the response, and in the first part, get each Key:Value pair. I might not even need them all, but I have to look at each one to see what the values are then decide what to do with it. I'm currently writing the response out to a textbox just to understand what its doing, but now I need to actually do something with the data. Here's a data sample, as it is received: ANS Result: Data Received RCPRES:Q[81] TML:123 OPP: MRR:000000999999 <several dozen more KEY:Value pairs> RCTNov 05 2013 04:03 pm Trans# 123456 <pre-formatted text>

    Read the article

  • How to check of which user-defined type a current JSON element is during $.each()?

    - by Bob
    I have the following structure for a JSON file: ({condos:[{Address:'123 Fake St.', Lat:'56.645654', Lng:'23.534546'},{... another condo ...},{...}],houses:[{Address:'1 Main Ave.', Lat:'34.765766', Lng:'27.8786674'},{... another house ...}, {...}]}) So, I have a list of condos and houses in one big JSON array. I want to plot them all on my map, but I want to give condos and houses different marker icons( blue marker for condos, green marker for houses ). Problem I have is - figuring out how to distinguish between types of markers when I $.each() through them. How would I use if to check whether I'm working with a condo or a house at the moment? var markers = null; $('#map').gmap(mapOptions).bind('init', function(){ $.post('getMarkers.php', function(json){ markers = json; $.each(markers, function(type, dataMembers) { $.each(dataMembers, function(i, j){ //if house use house.png to create marker $('#map').gmap('addMarker', { 'position': new google.maps.LatLng(parseFloat(Lat), parseFloat(Lng)), 'bounds':true, 'icon':'house.png' } ); //if condo use condo.png $('#map').gmap('addMarker', { 'position': new google.maps.LatLng(parseFloat(Lat), parseFloat(Lng)), 'bounds':true, 'icon':'condo.png' } ); }); }); }); });

    Read the article

  • subset complete or balance dataset in r

    - by SHRram
    I have a dataset that unequal number of repetition. I want to subset a data by removing those entries that are incomplete (i.e. replication less than maximum). Just small example: set.seed(123) mydt <- data.frame (name= rep ( c("A", "B", "C", "D", "E"), c(1,2,4,4, 3)), var1 = rnorm (14, 3,1), var2 = rnorm (14, 4,1)) mydt name var1 var2 1 A 2.439524 3.444159 2 B 2.769823 5.786913 3 B 4.558708 4.497850 4 C 3.070508 2.033383 5 C 3.129288 4.701356 6 C 4.715065 3.527209 7 C 3.460916 2.932176 8 D 1.734939 3.782025 9 D 2.313147 2.973996 10 D 2.554338 3.271109 11 D 4.224082 3.374961 12 E 3.359814 2.313307 13 E 3.400771 4.837787 14 E 3.110683 4.153373 summary(mydt) name var1 var2 A:1 Min. :1.735 Min. :2.033 B:2 1st Qu.:2.608 1st Qu.:3.048 C:4 Median :3.120 Median :3.486 D:4 Mean :3.203 Mean :3.688 E:3 3rd Qu.:3.446 3rd Qu.:4.412 Max. :4.715 Max. :5.787 I want to get rid of A, B, E from the data as they are incomplete. Thus expected output: name var1 var2 4 C 3.070508 2.033383 5 C 3.129288 4.701356 6 C 4.715065 3.527209 7 C 3.460916 2.932176 8 D 1.734939 3.782025 9 D 2.313147 2.973996 10 D 2.554338 3.271109 11 D 4.224082 3.374961 Please note the dataset is big, the following may not a option: mydt[mydt$name == "C",] mydt[mydt$name == "D", ]

    Read the article

  • get random password with puppet function

    - by ninja-2
    I have a function that allow me to generate random password. My function is working well without a puppetmaster. When i tried with a master an error appear when I called the function : Error 400 on SERVER: bad value for range Here is my function module Puppet::Parser::Functions newfunction(:get_random_password, :type => :rvalue, :doc => <<-EOS Returns a random password. EOS ) do |args| raise(Puppet::ParseError, "get_random_password(): Wrong number of arguments " + "given (#{args.size} for 1)") if args.size != 1 specials = ((33..33).to_a + (35..38).to_a + (40..47).to_a + (58..64).to_a + (91..93).to_a + (95..96).to_a + (123..125).to_a).pack('U*').chars.to_a numbers = (0..9).to_a alphal = ('a'..'z').to_a alphau = ('A'..'Z').to_a length = args[0] CHARS = (alphal + specials + numbers + alphau) pwd = CHARS.sort_by { rand }.join[0...length] return pwd end end The function is called in both case with $pwd = get_random_password(10). When I specified the length directly in the function to 10 for example. the password is well generated in master mode. Have you any idea why i can't specify the lentgth value ? Thanks for any help.

    Read the article

< Previous Page | 52 53 54 55 56 57 58 59 60 61 62 63  | Next Page >