Daily Archives

Articles indexed Sunday April 15 2012

Page 7/15 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Jquery Autocomplete after space press

    - by Limpep
    I am having an issue with my auto-complete feature such as when a user presses the space button the auto-complete doesn't show up again. Here is my code script type="text/javascript"> function lookup(inputString) { if(inputString.length == 0) { // Hide the suggestion box. $('#suggestions').hide(); } else { $.post("autocomplete.php", { queryString: ""+inputString+"" }, function(data){ if(data.length >0) { $('#suggestions').show(); $('#autoSuggestionsList').html(data); } }); } } // lookup function fill(thisValue) { $('#tag').val(thisValue); setTimeout("$('#suggestions').hide();", 200); } here my php code <?php require_once('config.php'); $db = new mysqli(DB_HOST, DB_USER, DB_PASSWORD,DB_DATABASE); if(!$db) { // Show error if we cannot connect. echo 'ERROR: Could not connect to the database.'; } else { // Is there a posted query string? if(isset($_POST['queryString'])) { $queryString = $db->real_escape_string($_POST['queryString']); // Is the string length greater than 0? if(strlen($queryString) >0) { // Run the query: We use LIKE '$queryString%' // The percentage sign is a wild-card, in my example of countries it works like this... // $queryString = 'Uni'; // Returned data = 'United States, United Kindom'; $query = $db->query("SELECT name FROM tag WHERE name LIKE '$queryString%' ORDER BY name LIMIT 10"); if($query) { // While there are results loop through them - fetching an Object (i like PHP5 btw!). while ($result = $query ->fetch_object()) { // Format the results, im using <li> for the list, you can change it. // The onClick function fills the textbox with the result. echo '<li onClick="fill(\''.$result->name.'\');">'.$result->name.'</li>'; } } else { echo 'ERROR: There was a problem with the query.'; } } else { // Dont do anything. } // There is a queryString. } else { echo 'There should be no direct access to this script!'; } } ? Any help would be great, thanks.

    Read the article

  • how to remove error text from the email format checker code?

    - by rdesai
    I have been writing a code for validating forms using javascript/jquery. Following is a code snippet for checking email format. The problem is when I enter invalid email, it recognizes it, but when I go back to this field and enter correct email, the error text still stays even though I have used the 'else' part. How do I remove the error text in this case? if(e1.value!=''){ var emailRegEx = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i; if (document.signupForm.email1.value.search(emailRegEx) == -1) { $("#err_email1").html("Please enter valid email address."); } status=0; } else{ $("#err_email1").html(""); status=1; }

    Read the article

  • Filter of Data in Gridview logical error please using asp.net

    - by RajuBabli Abbasi
    I wanted to filter the Data in asp.net but my Data is not filtering i have some logical error So please help me for this case i will be very thanks full to those who will help me please consider my code and replay me with code if you can so please i am waiting for your replay thanks again my asp.cs file is protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DisplayStudentInformation(); } } private void DisplayStudentInformation() { string filter = "%" + filterTextBox.Text + "%"; if (filter == String.Empty) filter = "%"; try { using (SqlDataReader reader = DAC.GetCompanyInformation(filter)) {//reader.Read(); StudentGridView.DataSource = reader; StudentGridView.DataBind(); } } catch (SqlException ex) { StatusLabel.Text = ex.Message; } } my .aspx file is asp:Table ID="Tabel" runat ="server" asp:TableRow asp:TableCell asp:Label ID="filterLabel" runat ="server" Text ="Company Name Filter:" AssociatedControlID="filterTextBox" /asp:TableCell asp:TableCell asp:TextBox ID="filterTextBox" runat="server" MaxLength ="50" /asp:TableCell asp:TableCell asp:Button ID="refreshButton" runat ="server" Text ="Filter" CausesValidation="false" / /asp:TableCell /asp:TableRow /asp:Table My DAC file is public static SqlDataReader GetCompanyInformation(string filter) { SqlDataReader reader; string sql = "SELECT * FROM Student WHERE LastName LIKE @prmLastName "; using(SqlCommand command = new SqlCommand (sql,ConnectionManager.GetConnection())) {//In ExecuteReader we pass the CommandBehavior as singleResult because we need the Single result and also passing the close connection when Datais retriev // command.Parameters.Add("@prmLastName", SqlDbType.VarChar, 25).Value = filter; command.Parameters.AddWithValue("@prmLastName", filter); reader = command.ExecuteReader(CommandBehavior.SingleResult | CommandBehavior.CloseConnection); } return reader; } Note:- When i don't use the If(!Ispostback) Condition and simply pass the DisplayStudentInformation(); method in my page load then Data can be filter but with If(!IspostBack ) condition which is also important for updating the data and for other purpose . Data can be filter . Se aim of the expert is that Filter the Data in a gridview using condition of IF(!IspostBack ) means without the removing is post back condition Filter the Data . I have been ask other about this question but no body solve this so please help me i will be very thanks full to you all ok

    Read the article

  • MYSQL, Subquery Reference in Union

    - by christian
    Is there any way to reference a subquery in a union? I am trying to do something like the following, and would like to avoid a temporary table, but the subquery will be drawn from a much larger dataset so it makes sense to only do it once.. SELECT * FROM (SELECT * FROM ads WHERE state='FL' AND city='Maitland' AND page='home' ORDER BY RAND()) AS sq WHERE spot = 'full-banner' LIMIT 1 UNION SELECT * FROM sq WHERE spot = 'leaderboard' LIMIT 1 UNION SELECT * FROM sq WHERE spot = 'rectangle1' LIMIT 1 UNION SELECT * FROM sq WHERE spot = 'rectangle2' LIMIT 1 .... etc,, It's a shame that DISTINCT can't be specified for a single column of a result set.

    Read the article

  • Is there any algorithm that can solve ANY traditional sudoku puzzles, WITHOUT guessing (or similar techniques)?

    - by justin
    Is there any algorithm that solves ANY traditional sudoku puzzle, WITHOUT guessing? Here Guessing means trying an candidate and see how far it goes, if a contradiction is found with the guess, backtracking to the guessing step and try another candidate; when all candidates are exhausted without success, backtracking to the previous guessing step (if there is one; otherwise the puzzle proofs invalid.), etc. EDIT1: Thank you for your replies. traditional sudoku means 81-box sudoku, without any other constraints. Let us say the we know the solution is unique, is there any algorithm that can GUARANTEE to solve it without backtracking? Backtracking is a universal tool, I have nothing wrong with it but, using a universal tool to solve sudoku decreases the value and fun in deciphering (manually, or by computer) sudoku puzzles. How can a human being solve the so called "the hardest sudoku in the world", does he need to guess? I heard some researcher accidentally found that their algorithm for some data analysis can solve all sudoku. Is that true, do they have to guess too?

    Read the article

  • C struct written in file, open with Java

    - by DaunnC
    For example in C I have structure: typedef struct { int number; double x1; double y1; double x2; double y2; double x3; double y3; } CTRstruct;` Then I write it to file fwrite(&tr, 1, sizeof(tr), fp); (tr - its CTRstruct var, fp - File pointer); Then I need to read it with Java! I really don't know how to read struct from file... I tried to read it with ObjectInputStream(), last idea is to read with RandomAccessFile() but I also don't know how to... (readLong(), readDouble() also doesn't work, it works ofcource but doesn't read correct data). So, any idea how to read C struct from binary file with Java? If it's interesting, my version to read integer (but it's ugly, & I don't know what to do with double): public class MyDataInputStream extends DataInputStream{ public MyDataInputStream(InputStream AIs) { super(AIs); } public int readInt1() throws IOException{ int ch1 = in.read(); int ch2 = in.read(); int ch3 = in.read(); int ch4 = in.read(); if ((ch1 | ch2 | ch3 | ch4) < 0) throw new EOFException(); return ((ch4 << 24) + (ch3 << 16) + (ch2 << 8) + (ch1 << 0)); } with double we can deal the same way (like with int or with long (8bytes) & then convert to double with native func).

    Read the article

  • Securing database keys for client-side processing

    - by danp
    I have a tree of information which is sent to the client in a JSON object. In that object, I don't want to have raw IDs which are coming from the database. I thought of making a hash of the id and a field in the object (title, for example) or a salt, but I'm worried that this might have a serious effect on processing overhead. SELECT * FROM `things` where md5(concat(id,'some salt')) = md5('1some salt'); Is there a standard practice for obscuring IDs in this kind of situation?

    Read the article

  • deploying a simple html website with eclipse EE & tomcat 7 & router for pc not in LAN

    - by hawkeye
    Hello everyone and thanks for your time, first of all - I want to make a note - I can see the website from my own pc which is the only one connected to the (netgear dgn1000) router, and I can do so with several browsers on my pc, but - when I try and do a port forwarding so that I could access this simple html file (which in the way would use a simple servlet class) I can't seem to view it I have configured my router (both the "services" and the "firewall" sections), and I have also changed my LAN properties according to my ISP's explanation (via phone) : instead of choosing the "obtain an IP address automatically" I have chosen the "use the following IP address, with IP address of 10.0.0.1 (this was also set in the router's port forwarding), Subnet mask of 255.255.255.0, default gateway by checking the same value as seen in the cmd when executing the command ipconfig /all after doing so I've changed the DNS to use the address (just the preferred and not the alternate one) given with the ipconfig /all and still - nothing :/ is it something in my network settings or in my deployment of the eclipse/tomcat ? any help would be greatly appreciated, thanks :)

    Read the article

  • getting code in new line

    - by Man Behind
    I have several divs one of which is as below <div id="drawarea"> <img class="draggable ui-droppable ui-draggable ui-draggable-dragging" id="image1" src="user_2/1323384165.jpg" style="height: 40%; width: 50%; position: absolute; left: 0%; top: 0%;"> <label id="first">This is content of the div</label> <input type="button" value="GO"/> </div> I am using jquerys below function to get the html inside the div and put in a text area html = $('#drawarea').html(); $('#codearea').text(html); the problem is that i am getting all the tags in same line i want to get one element code in one then others on other line so thats its easy to read.

    Read the article

  • How can I set the Jbuttons in a preferred order?

    - by Umzz Mo
    I have a grid of 30 buttons, and I want to have it from left to right then goes down, right to left, down again left to right. Basically the numbering would be as follow: 1 2 3 4 5 6 7 8 9 10 20 19 18 17 16 15 14 13 12 11 21 22 23 24 25 26 27 28 29 30 So if I have a piece on the button 10 and I instruct it to move up 2 bits it would land on 12 not 19. Below is my Code: //Creates the button using the loop, adds it into the panel and frame. JPanel panel = new JPanel(); panel.setLayout(new GridLayout(3,10)); JButton [] buttons = new JButton[30]; for(int i=0;i<30;i++){ buttons[i] = new JButton("label" + i); buttons[i].setBackground(Color.white); //Puts the player 1 piece on button 1,3,5,7,9 and player 2 piece on button 2,4,6,8,10 if (i < 10) { if (i%2 == 0) { buttons[i].setIcon(piece1); } else { buttons[i].setIcon(piece2); } } panel.add(buttons[i]); } frame.add(panel, BorderLayout.CENTER);

    Read the article

  • Is there an easier way to do Classic ASP "relative path"?

    - by Alex.Piechowski
    Right now, I'm having trouble. First of all I have a page, let's call it "http://blah.com/login". That obviously goes strait to "index.asp" A line of Main.asp: <!--#include file="resource/menu.asp"--> Page top includes all of what I need for my menu... so: Part of resource/menu.htm: <div id="colortab" class="ddcolortabs"> <ul> <li><a href="main.asp" title="Main" rel="dropmain"><span>Main</span></a></li> ... </ul> </div> <!--Main drop down menu --> <div id="dropmain" class="dropmenudiv_a"> <a href="main/announcements.asp">Announcements</a> <a href="main/contacts.asp">Contact Information</a> <a href="main/MeetingPlans.asp">Meeting Plan</a> <a href="main/photos.asp">Photo Gallery</a> <a href="main/events.asp">Upcoming Events</a> </div> Let's say I click on the "announcements" (http://blah.com/login/main/announcements.asp) link... Now I'm at the announcements page! But wait, I include the same menu file. Guess what happens: I get sent to "http://blah.com/login/main/main/announcements.asp Which doesn't exist... My solution: Make a menu_sub.asp include for any subpages. But wait a second... this WORKS, but it gets REALLY REALLY messy... What can I do to use just one main "menu.asp" instead of "menu_sub.asp"? using "/main/announcements.asp" WON'T be an option because this is a web application that will be on different directories per server. Any ideas? PLEASE

    Read the article

  • Node.js + express.js + passport.js : stay authenticated between server restart

    - by Arnaud Rinquin
    I use passport.js to handle auth on my nodejs + express.js application. I setup a LocalStrategy to take users from mongodb My problems is that users have to re-authenticate when I restart my node server. This is a problem as I am actively developing it and don't wan't to login at every restart... (+ I use node supervisor) Here is my app setup : app.configure(function(){ app.use('/static', express.static(__dirname + '/static')); app.use(express.bodyParser()); app.use(express.methodOverride()); app.use(express.cookieParser()); app.use(express.session({secret:'something'})); app.use(passport.initialize()); app.use(passport.session()); app.use(app.router); }); And session serializing setup : passport.serializeUser(function(user, done) { done(null, user.email); }); passport.deserializeUser(function(email, done) { User.findOne({email:email}, function(err, user) { done(err, user); }); }); I tried the solution given on this blog using connect-mongodb without success app.use(express.session({ secret:'something else', cookie: {maxAge: 60000 * 60 * 24 * 30}, // 30 days store: MongoDBStore({ db: mongoose.connection.db }) }));

    Read the article

  • using LARGE_INTEGER gives me back error error C2679: '=' binary no operator found which takes a right-hand operand

    - by rekotc
    i have the following code: QueryPerformanceCounter(&timeStart); winMain::render(); //do stuff QueryPerformanceCounter(&timeEnd); numCounts = ( timeEnd.QuadPart - timeStart.QuadPart); All the 3 variables are declared as LARGE_INTEGER, the code should work since im following a book example, but i get: error C2679: '=' binary no operator found which takes a right-hand operand of type LONGLONG it might be '_LARGE_INTEGER &_LARGE_INTEGER::operator =(const _LARGE_INTEGER &)' 1 durante la ricerca di corrispondenza con l'elenco di argomenti '(LARGE_INTEGER, LONGLONG)'

    Read the article

  • Android - ListActivity, add Header and Footer view

    - by Victor
    I'm using ListActivity, listview. listView = getListView(); just working perfectly. I added footer view as LayoutInflater inflater = getLayoutInflater(); listView.addFooterView( inflater.inflate( R.layout.footer, null ), null, false); and everything was shiny but ugly, so i wanted to add this footer view (which contains only 1 edittext and only 1 button ) to header of listView as LayoutInflater inflater = getLayoutInflater(); listView.addHeaderView( inflater.inflate( R.layout.footer, null ), null, false); and suddenly everything goes wrong, and i get RuntimeException immediately. Suspended(exception RuntimeException) ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord, Intent) ActivityThread.access$2200(ActivityThread, Activity$ActiviyRecord, Intent), so on.. Why is it throws exception ? What is different between addFooterView and addHeaderView, and how can i add Header to ListActivity ? UPDATE So as you can read in comments, my logcat still doesn't work, but i just tried next at this moment: } catch(Exception e){ Writer result = new StringWriter(); PrintWriter printWriter = new PrintWriter(result); e.printStackTrace(printWriter); String error = result.toString(); } and afterward i put breakpoint, and i can read error in expressions section. it said : java.lang.IllegalStateException: Cannot add header view to list -- setAdapter has already been called. it was instructive for all of us. After change sort of commands, it works perferctly.

    Read the article

  • WCF to WCF communication 401, HttpClient

    - by youwhut
    I have a WCF REST service that needs to communicate with another WCF REST service. There are three websites: Default Web Site Website1 Website2 If I set up both services in Default Web Site and connect to the other (using HttpClient) using the URI http://localhost/service then everything is okay. The desired set-up is to move these two services to separate websites and rather than using the URI http://localhost/service, accessing the service via http://website1.domain.com/service still using HttpClient. I received the exception: System.ArgumentOutOfRangeException: Unauthorized (401) is not one of the following: OK (200), Created (201), Accepted (202), NonAuthoritativeInformation (203), NoContent (204), ResetContent (205), PartialContent (206) I can see this is a 401, but what is going on here? Thanks

    Read the article

  • How to find specific row in MySQL query result?

    - by Šime Vidas
    So I do this to retrieve my entire table: $result = mysql_query( 'SELECT * FROM mytable' ); Then, in another part of my PHP-page, I do another query (for a specific row): $result2 = mysql_query( 'SELECT * FROM mytable WHERE id = ' . $id ); $row = mysql_fetch_array( $result2 ); So, I'm performing two querys. However, I don't really have to do that, do I? I mean, the row that I'm retrieving in my second query already is present in $result (the result of my first query), since it contains my entire table. Therefore, instead of doing the second query, I would like to extract the desired row from $result directly (while keeping $result itself in tact). How would I do that? OK, so this is how I've implemented it: function getRowById ( $result, $id ) { while ( $row = mysql_fetch_array( $result ) ) { if ( $row['id'] == $id ) { mysql_data_seek( $result, 0 ); return $row; } } }

    Read the article

  • Multiple use of a form before it is submitted

    - by OregonTrail
    I'm new to JavaScript, and trying to figure out the canonical way to do the following. I have a form with some checkboxes and a selector. Let's say the checkboxes are styles of music and the selector is for people's names. I'd like the user to be able to select the styles of music for each of the people's names and then submit the form with all of the data. For example, the user might first check off Classical, Jazz, Rock, and Pop and choose "Joe", then select Jazz, Pop, Country, and Electronica and choose "Jane". So there would have to be two different buttons for "submit person" and "submit form". I would like to: Have a list of the names and their chosen styles populate below the form, for feedback Allow the user to use the form as much as they want, and then submit all the data at the end I get the feeling that using jquery and JSON is perfect for this, but I'm not sure what search terminology to use to figure out how to do this. If it matters, the form will be processed by a Django view in Python.

    Read the article

  • Git pre-commit hook: getting list of changed files

    - by Mikko Ohtamaa
    I am developing validation and linting utility to be integrated with various commit hooks, including Git one https://github.com/miohtama/vvv Currently validators and linters are run against the whole project codebase on every commit. However, it would be much more optimal to run them against changed files only. For this, I would need to know changed files list in my Git precommit hook (in Python) https://github.com/miohtama/vvv/blob/master/vvv/hooks/git.py What options I have to extract the changed files list (in Python if that matters)?

    Read the article

  • Determining Terminal lines/cols via PHP CLI

    - by eFrane
    I know that it is quite easy to figure out a terminal's size parameters via the stty -a command. When using local CLI PHP scripts, there is no problem at all on grabbing that output via system() or so. But I am trying the same thing via a php script started from an ssh command. Sadly, all that stty ever returns is: stty: standard input: Invalid argument. The calling code is: exec('stty -a | head -n 1', $query); echo $query[0]; So the question is: If I can output to the terminal and read input from it (e.g. can fread() from STDIN and fwrite() to STDOUT in PHP, shouldn't stty also have valid STDIN and STDOUT?

    Read the article

  • Get height of DIV and it's content with JQuery

    - by user1012403
    I have a div which contains several elements: <div class="menuItem designMenu" id="dMenu"> <ul class="menuList menu"> <li class="menuHeader">Design</li> <li class="projectHeader">Mother</li> <li class="projectBody">Some text here</li> <li class="more">More</li> </ul> </div> I need to get the height of the dMenu items that I can animate it upwards, including all the content inside. My Javascript currently: var designHeight = $("#dMenu").height(); Returns nothing. I've tried offsetHeight, scrollHeight, and everything else Google turns up. I'm running the JQuery at the end of the body, inside a document ready function. The reason to get the height to animate, instead of doing it manually, is that a: I'd like to learn how and b: I don't yet know how many items will be int he div. Thanks.

    Read the article

  • UTF-8 support in java application

    - by jacekn
    I'm having trouble with UTF-8. common.jsp <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> typical.jsp <%@ include file="common.jsp" %> Page Head <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> Form <form id="screenObject" accept-charset="UTF-8" action="/SiteAdmin/articleHeaderEdit?articleId=15" method="post"> I enter non latin1 characters into a text field and click Save. Validator complains about another field and stops the submission. This never gets to the database, so database ability to handle UTF-8 is not in this picture. The page redisplays with appropriate error but the text that had been entered is all messed up. All non latin1 characters are converted to some gibberish. I'm using Spring 3 MVC, in case that matters... Attempts Adding this to my view resolver didn't help: <property name="contentType" value="text/html;charset=UTF-8" />

    Read the article

  • Socket left in TIME_WAIT after file transfer via netcat

    - by com
    Using Copying by NetCat I am trying to copy files throught network by NetCat. From console it work pretty well. First I run listening netcat on the destination machine and after I run sending on source machine. The problem is it's doen't work from script from the source machine: ssh -f user@$desthost 'nc -l 1234 | tar xvf - /dev/null &' #listening on destination host tar cv /tmp/file | nc $desthost 1234 #sending to destination host I saw that after running port 1234 is still was open and status of the socket was TIME_WAIT. If you know what's the problem, please, help me out. And by the way, after copying how can I validate that the content is identical? Thanks! Addendum: I found one very strange thing, the same implementation with screen on destination work works, but not stable, sometimes it doesn't copy a file. ssh user@$desthost screen -dm -S test 'nc -l 1234 | tar xvf - ' #listening on destination host Maybe there is an issue with timeout?

    Read the article

  • frame variable cannot be found

    - by Umzz Mo
    I am making 3 board games, and I have started my coding off in one class. Now that i wanted to move around it is giving me problems. In my view class I just want to have the main frame where users can pick from the games. And in the other views, i.e the childrens of view class i want to have the interface for the actual games. Now that the Jframe frame = new frame was created in the parent class, it cannot find the variable frame in the children classes.

    Read the article

  • mysql order-by original "where order"

    - by Benjamin Dobnikar
    I have this order-by problem I canot crack. I select from my table like this: SELECT * FROM 'sidemodules' WHERE name = 'module1' OR name = 'module2' OR 'name3' Which returns me the modules I want. But the modules lie the table, say in this order: module3 module1 module2 And they are returned to me in this order. How can I get them to display in order AS IN THE WHERE CLAUSE (1,2,3) ? Big thanks!

    Read the article

  • Get scanner to include but ignore quoted text?

    - by user1086516
    Basically my problem is this, I need to parse text where , is the delimiter but anything in " " quotes should not be checked for a delimiter. Is this what the Scanner.skip method is for? I would check it myself but I don't understand how to write a regex pattern in java where the token is something in between two " ". I also want to include any quoted text in the proper token which was delimited by the valid ,.

    Read the article

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