Jump to content

phdphd

Members
  • Posts

    248
  • Joined

  • Last visited

Everything posted by phdphd

  1. Thanks again. As for the plugin I guess you mean jQuery UI 1. 8.18. I am going to investigate your solution right know.
  2. Thank you for answering and for your suggestion. Sorry, I am using jquery-1.7.2.js. Regards.
  3. Hi All, I have a form with a jquery autocomplete input field. Once the user has entered 2 characters, there is a list of values (people names) containing this string that appears. This works good. The values come from a database table with two fields (names and ids). The query that extracts the names also retreives the values in the id field. What would be the syntax to set the "value" attribut of the input tag to the id of a name when the user clicks on that name in the list? The PHP part that builds the json is : $data[] = array( 'label' => $row['name'], 'value' => $row['name'], 'id' => $row['id'] ); echo json_encode($data); The JS begins as follows : jQuery(document).ready(function(){ $('#input_id').autocomplete({source:'my_jquery_suggest.php', select: function(event, ui) { $(event.target).val(ui.item.value); $('#form_id').submit(); return false; }, minLength:2,delay: 1000}).focus(function () { window.pageIndex = 0; $(this).autocomplete("search"); }); ... Thanks for your help.
  4. Hi All, I have a form that enables the user to know events that occur in a specific city. Most of the time they get the results in a few seconds, despite the fact that many rows in various tables might be searched for detailed infos about the events in that city. However, this form partly relies on a table against which a MySQL event regularly does some operations. If the user uses the form while the event is being executed, they have to wait up to 30 seconds before getting the results, and sometimes only part of the html page is generated. Is there a way to avoid this lengthy waiting time ? I am wondering whether or not the best would be putting the site on maintenance while the event is being executed, with a "please come back in a few minutes" message. Thanks in advance for your help.
  5. Hi All, I have a problem with masonry. I initially have a scrollable area that contains DIVs with fixed width. Each DIV contains info about an event, and consists of two DIVs, an upper one, and a lower one. When the user has JS enabled, only the upper one part displays. They can display the lower DIV by clicking a plus sign. Without masonry, this clicking operation will create a blank area. I woud like to get rid of this blank area. I tried to implement masonry, but the result is that when the lower part of a div is displayed, it overlaps the upper part of the div below it. At this stage I defined no options for masonry. I just installed masonry.pkgd.min.js and add class="js-masonry" to the scrollable area. Thank you for your help !
  6. Hi All, I have an html input tag with an associated jquery autocomplete feature. So far, I have been using the following jQuery setting : jquery-1.9.1.js http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/smoothness/jquery-ui.css http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js Now, since the list may contain a lot of items and take some time to load if the user types a string that appears in many items, I want to associate an infinite scroll with the autocomplete feature. The infinite scroll would load items 5 at a time when the user scrolls the list down. I found a jsfiddle (http://jsfiddle.net/EVsye/83/) based on a previous jQuery setting (jquery 1.7.2, jquery UI 1.8.18) that illustrates this feature. I tried to update this jsfiddle to my jQuery setting. However there are 2 issues : 1. The user cannot select an item in the list. 2. Items beyond the 5th one seem to have no css applied to them (they are not aligned to the first 5 ones and the mouseover formatting has no effect on them). I would much appreciate your help. My jsfiddle : http://jsfiddle.net/Lp6zP/ Thanks!
  7. Thanks mac gyver!
  8. Hi All, I have found an interesting source about computing the shortest route given any given number of points, here. However it takes too long above 7 points (around 4 seconds with 7 points, more than 30 sec with 8 points). Does anyone know a quicker solution ? Thanks!
  9. Hi All, I am trying to find a way to hide the Browse button when the user checks a box. I found the solution when the page has just one pair of browser button/checkbox (http://jsfiddle.net/xSvLc/53/). However since the PHP-generated form is likely to contain multiple browser button/checkbox pairs, I do not know how to implement the JS function in this situation. I tried to (http://jsfiddle.net/xSvLc/58/), but it does not work. Thanks for your help ! PhD
  10. Thank you for your answer Jazz !
  11. Hi All, Is recreating an uploaded image an efficient way to protect it against a potential virus ? I came across this solution at the following address : http://security.stackexchange.com/questions/26690/use-php-to-check-uploaded-image-file-for-malware at the paragraph starting with "Best I can think for PHP is to re-create the image". Thanks
  12. I nearly found the solution by replacing the while loop contents with the following var str1 = suggestions[i]; var str2 = beginning; var str2 = str2.replace(/\*/g, ""); var re = new RegExp(str2,"i"); if (str1.search(re) == -1) { correct = 0; } However there is still an issue with the * character. If the user types "*", all the suggestions are displayed. Without the line "var str2 = str2.replace(/\*/g, "");", If the user types "*" no suggestion is displayed, but if they type any character followed by "*", then all the suggestions are displayed. I also noticed some similar issues with the use of "?". What I want is to avoid the displaying of all the suggestions if wildcards are typed, or to have them processed as normal characters. Thanks for your help.
  13. Thanks for your answer. I managed to solve it, but still have 2 problems after having implemented case-insensitiveness. The getWord function now looks as follows : function getWord(beginning) { var words = new Array(); for (var i=0;i < suggestions.length; ++i) { var j = -1; var correct = 1; while (correct == 1 && ++j < beginning.length) { if (suggestions[i].indexOf(beginning.toLowerCase()) === -1) { if (suggestions[i].indexOf(beginning.toUpperCase()) === -1) correct = 0; } } if (correct == 1) words[words.length] = suggestions[i]; } return words; } Assuming the "suggestions" are ["Hello","World","Hello World","hELLO"], the issues are : 1. Any string representing 2 beginning letters, whatever their case, will match no results. For example, "HE", "He", "hE", "he" do not match "Hello", neither "hELLO", nor "Hello World", whereas "lLo" will match the three of them. 2. " w" and " W" will match "Hello World", but "o W" will not. Any idea of how to solve these issues ? Thanks!
  14. Hi All, I have found an interesting autocomplete js code at http://hscripts.com/scripts/JavaScript/autocomplete-form.php that works without jQuery and grabs data from a php array. I managed to have the data extracted from a database first and I am using the following piece of PHP code inside the JS suggestions variable to feed this variable : $tmp = Array(); foreach($tab as $k=>$v) { $tmp[] = '"'.addslashes($v).'"'; } echo join(',', $tmp); I use addslashes because I noticed that the autocomplete does not work if one of the retreived words contains a double-quote. Is this enough to protect JS coding ? I also would like to make this JS code search for the typed characters at any position in the strings (not just from the beginning). Is this feasible ? Thanks! PS/ I also made the JS case insensitive by applying the following tip : http://www.vonloesch.de/node/18#comment-2832
  15. Hi All, The heredoc syntax enables to put some text in a variable for future reuse. For example : $my_var = <<<EOD The colour is red. EOD; echo $my_var; will result in "The colour is red". So far so good. Now let's assume the following: $colour="red"; $my_var = <<<EOD echo 'The colour is '.$colour; EOD; echo $my_var; Unfortunately the result will be "echo 'The colour is '.red;". In this situation, is there a way to tell php to just put "The colour is red" into the $my_var variable ? Or is there an alternative to heredoc ? Thanks!
  16. Thanks for your replies. Shame on me. In Firefox, to display the html output of the text of interest, I made the mistake to select a portion of the form that spans that text, then right-click and choose to display the source code of the selection, in order to visually locate the text quickly. I did not pay attention to the fact that the html output did not span the whole page. One learns a bit every day. Sorry for the time lost. Both htmlentities and htmlspecialchars do the job.
  17. Hi All, I am applying some htmlspecialchars to strings before displaying them to the user. In theory, there are 2 situations : 1/ when the user submits a form, I display the just-entered data as plain text at the top of the next form to tell the user that their entries have been taken into account. 2/ Should the user make a mistake while filling a form, the form is displayed again with form fields ("value" parameters of input tags) prefilled so that correctly-entered data does not need retyping. In both cases, I use the syntax echo htmlspecialchars($string) to display the data. To simulate both cases at the same time, I have put echo htmlspecialchars($string) both into a "value" parameter of an input tag and outside this input tag, and left some mandatory fields blank to force the form to display again. The string tested is <<<<<<"<<<<<<. From the user's point of view, the string is reproduced as is in both cases. However the html output differs : where the string is plain text, the html output is <<<<<<"<<<<<< (every character is converted except the double quote), whereas where the string is the content of the "value" parameter of the input tag, the html output is <<<<<<"<<<<<< (only the double quote is converted). I have 3 questions : 1. Since I did not use ENT_NOQUOTES, why the double quote did not get converted in the plain text situation ? (official doc : '"' (double quote) becomes '"' when ENT_NOQUOTES is not set. ). 2. Why the "less than" characters remained untouched in the input tag situation (official doc : '<' (less than) becomes '<' ). 3. Does this apparent lack of conversions bear some risks as far as the html structure of the whole page is concerned? Thanks! (PHP version : 5.3.25)
  18. Thanks for your answer. Yes, I use sessions. Files are saved without BOM. No errors reported. (To be more precise there is a warning reported about the use of the php date function in the file, but as I wrote in my post, the issue also occurs when the file contains no php code). BTW I see no "Apply to opened ANSI files" equivalent option in my Notepad++ French version. However "ANSI as UTF-8" appears at the bottom right of Notepad++ status bar. Edit : I misread your Notepad++ sequence. Yes, the "UTF-8 without BOM, Apply to opened ANSI files" option is selected.
  19. Hi All, I would like to share a strange experience with you and get your opinion about it. The issue is that a php file is not processed as expected, apparently due to the html code line <meta charset="utf-8" />, hence the presence of my post in the HTML section of the Forum. My config is PHP 5.3.25/Mysql 5.6.11. I am trying to adjust my website so that it is fully utf-8 aware. I am presently adjusting all my php files for that purpose. Basically, I have an index.php file with links to different processes the user can start. Every process involves a series of forms and is made up of one file (called process-to-do.php) and a series of php files that the process-to-do.php file calls one after the other via include file instructions (every included file contains a form). All works great. In Notepad++ (with default encoding previously set to utf-8 ) in order to make every php file utf-8 aware, and to avoid retyping all the code, I sequentially created a new php file, saved it with the same name as the legacy non-utf-8 file, and pasted a basic html5 code structure in it. Then I pasted the legacy pieces of code and made utf-8 adjustments where appropriate. FYI the basic html5 code structure I insert is <!DOCTYPE html> <html lang="fr"> <head> <meta charset="utf-8" /> <title>Titre</title> <link rel="stylesheet" href="style.css"> </head> <body> </body> </html> This process worked great until a certain file was called for inclusion. What happens visually is that this file is not displayed and that the index.php file is displayed instead. In other words the user is redirected back to the starting point where they choose what to do, without the ability to validate the form in the called file and to go to the next step. At first sight it seems that the called file is just ignored. But actually it is not. I noticed that the php contents of the file is successfully processed (there is some php that sends some data to a database and that job is done). I first thought that some php code was corrupted and causing the issue. I deleted the php code and I reexecuted the process. Again, the file would not display and the user would be redirected back to the starting point (index.php file). This indicated that php code was not causing the issue. OK. So I thought the form html code itself was corrupted. I deleted it and I reexecuted the process with only the basic html5 code structure in the file. Again, the file would not appear and the user would be redirected back to the starting point (index.php file). This indicated that the form html code was not causing the issue. OK. So I thought "let's do it the other way by keeping only the form html code, without html5 code structure". I reexecuted the process and that time, the file displayed, though with incorrect accent formatting due to the absence of the html utf-8 formatting. To go further I decided to add just the head section to the file to see if I could recover the utf-8 formatting. Failure again : the file would not appear and the user would be redirected back to the starting point. So I added the doctype and the html tags, without the head section. That time, the file displays again, though with incorrect accent formatting due to the absence of the html utf-8 formatting. Then I added the head section without the <meta charset="utf-8" /> line to get a 99,999% confirmation that this single line was causing the issue. As expected, the file displayed again, though with incorrect accent formatting due to the absence of the html utf-8 formatting. I made a final test -BTW congratulations to all of you who reached that point in my post - by inserting the header('Content-type: text/html; charset=utf-8'); php piece of code at the beginning of the included php file, and then the file was correcty processed and displayed. My questions are (a) why can a mere <meta charset="utf-8" /> line apparently cause such an issue, and (b) why in this included php file and not in the previous ones in the sequence ? Thanks!
  20. Thanks a lot Requinix. I think the problem was that my php file was initially a non-utf-8 file that I had resaved to utf-8. I created a new php file, saved it to utf-8 format, then pasted in it some pieces of code. So for whom it may be useful, the pregmatch regex instruction that works for me is if (preg_match('#[[:alnum:]]#u', $_POST['regex'])) One can even mix chars from left-to-right and right-to-left alphabets. Thanks again, have a nice Sunday.
  21. Thanks for your reply. Unfortunately neither works when special chars are involved, like in the German string "Schönen Tag". Is there something wrong in my UTF-8 setting ? My php file is UTF-8 saved and the contents of the POST is converted to UTF-8 using htmlspecialchars($_POST['regex'], ENT_NOQUOTES, 'UTF-8');.
  22. Indeed, this is the first thought that came to my mind when I woke up this morning . So coming back to your suggestion and since the character encoding is UTF-8, what would be the right regex syntax combining [[:alnum:]] with the /u flag ? All regexes that I tried (like /#[[:alnum:]]#/u) return either false or a modifier issue. Thanks.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.