Jump to content

jesh

Members
  • Posts

    2,293
  • Joined

  • Last visited

Everything posted by jesh

  1. Yeah, with AJAX you can even send a HEAD request rather than a GET or POST - it might speed things up a bit. You'll have to get the file information one file at a time.
  2. I think which one takes precedent is up to you. I would suggest, however, that since the quotes are at the most atomic level (i.e. a quote can belong to one or more categories but a category cannot belong to a quote), any settings specific for a quote should take precedent over settings specific for a category.reportingsjr's suggestion is good because it would prevent any conflict between multiple settings.
  3. You could set a variable to keep track of whether CTRL is pressed and check it when you look for what key is being pressed: var isCtrl = e.ctrlKeyswitch(keycode){ case 48: // b if(isCtrl) // make bold! break; case 23: // i if(isCtrl) // make italic! break;}
  4. Check out this page, Choco: http://www.w3schools.com/htmldom/event_ctrlkey.asp e = (e) ? e : window.event;var keycode = (e.which) ? e.which : e.keyCode;if(e.ctrlKey && keycode == 13){ alert("CTRL-ENTER was typed!");}
  5. jesh

    Top

    Does this validate and solve your problem? .myclass { top: 0px; } /* for IE */html>body .myclass { top: -2px; } /* for W3C */
  6. In firefox, you can choose Tools->Options to load up the browser options. Then on the "General" tab, there's a place where you can specify the default font. I'm sure there is something similar in IE. However, this is only going to change the way your particular browser displays the content. If you would like to be able to make it so that all browsers viewed the content in Arial font rather than Times New Roman, then you'll have to use HTML and/or CSS. Otherwise, the viewer's browser will look at the content as plain-text and display it however that browser is currently set up to display it.
  7. Using CSS, you can specify the default font for the body or for all elements:For the body (and everything else in it...) body { font-family: arial; font-size: 11px; } or for every element on the page * { font-family: arial; font-size: 11px; } Otherwise, you'll have to wrap the output in an HTML element. Something like this: <p><%="value1"%></p>
  8. jesh

    Whoa...

    Wait until you start learning about Quantum Mechanics and how it is theoretically possible, though highly improbable, that a person could walk through a wall or fall through the earth and how electrons may only exist because we think that they exist and we observe them to exist.
  9. jesh

    Prevent SQL injections?

    I generally prevent them by 1) only running stored procedures against the database and 2) converting all of the inputs into the appropriate data types. For example, if I expect a number to be inputted, I will attempt to convert that input to an integer or a float/double, etc before I attempt to access the database with that data.A first step is to simply escape the input so that single quotes (') are escaped (\'). Since you are using PHP, I believe the function you are looking for is mysql_escape_string(). If I'm wrong, I'm sure a PHP expert on here can correct me. :)Wikipedia has a great article on SQL injection. It also describes ways to prevent it:http://www.wikipedia.org/wiki/Sql_injectionGood luck!
  10. jesh

    opening a new window

    To keep the child window (the popup) open and to disallow interacting with any other windows, you might try adding an event handler to the blur event of the window. Something like this: window.onblur = function() { window.focus(); } To pass information to the parent window, you can get a reference to the parent by using window.opener. For more information about that, look here:http://www.w3schools.com/htmldom/prop_win_opener.asp
  11. Like boen_robot suggested, if you declare a variable inside of a function, the scope of that variable is for that function alone. The only way to access it would be to do one of the following:1) Declare the variable first and write directly to that global $array variable. $array;function queryTable($tableName,$select,$where,$orderbyASC_DESC,$limit) 2) Declare the variable first and pass a reference to it to your function: $array;function queryTable($tableName,$select,$where,$orderbyASC_DESC,$limit, &$array)// I don't know if &$array is the way to do it...in C# it'd be "out array" 3) Or, this is the most common way, assign the return value of the function to a local variable $array = queryTable(.....);
  12. jesh

    problems with DOM

    I'm not sure with what language you are trying to accomplish this, but in javascript, it'd look something like this: function addElement(parent, element_id, element_type){ var element = document.createElement(element_type); element.id = element_id; parent.appendChild(element);} And you could use it like this: var div = document.getElementById("mydiv");addElement(div, "test", "p");
  13. You might start by posting what code you already have. Also, try describing how the discount is calculated in plain english - that'll make turning it into javascript easier.
  14. You can do just about whatever you want. If you have a table which holds your user information (i.e. UserName, Password, UserID, etc), you could either add two more columns - FirstName, LastName - or you could add another table: or Then, when the user logs into your site, you'll be able to retreive the user's UserID from your database. With that, you can look up their display name.
  15. Ah, each time you click the button, a new timer starts. So, if you click the button three times, there will be three timers, each of which will be increasing your c variable by one. This would explain why you are seeing the counter speed up when you click the button multiple times. You'll need to have a separate function that happens when a user clicks on the button. This function will stop any timers that happen to be running and will reset the counter to 0.Perhaps something like this will help: <html><head><script type="text/javascript">var c = 0;var t;function startTimer(){ // first step, if there is a timeout happening, let's clear it. if (t) { clearTimeout(t); } // second step, let's reset the counter to 0 c = 0; // finally, let's start the timer timedCount();}function timedCount(){ document.getElementById('txt').value = c; c++; // this is the same as c=c+1 t = setTimeout("timedCount()",1000);}</script></head><body><form><input type="button" value="Start count!" onClick="startTimer()"><input type="text" id="txt"></form><p>Click on the button above. The input field will count for ever, starting at 0.</p></body></html>
  16. To bring a window to the front, you can set its focus: window.focus() It is not, however, possible to have a popup window remain on top while the user interacts with the window behind it. The only way you can make something like this happen is if you use a div within the main window and set it's z-index to be bigger than the other elements on the page so that it looks like a window that is floating above all the rest of the content.
  17. Can you post the code that you already have?
  18. Maybe if you had a specific question, or if you had some code that you haven't been able to implement, you could start a new post and someone here can help clear up any confusions you might have.
  19. jesh

    Ajax

    In my experience, the server side of AJAX (i.e. PHP, ASP.NET, etc.) is developed the same as you would for any other page. The only thing that you might consider is when you want to use XML as the response rather than text. In this case, you'll need to set the content-type for the response to "text/xml" rather than "text/html" or "text/plain".
  20. You might also try "toFixed(n)". var nbr=0.0000000001;document.write(nbr.toFixed(10));
  21. jesh

    T-SQL PIVOT

    OK, I found the answer here:http://msdn.microsoft.com/msdnmag/issues/0...;fig=true#fig13In case someone else comes across this, it basically involves the following steps:1) Using a WHILE loop, loop through all the ids and turn it into a varchar variable (I called it @InPart) that looks like "[1],[4],[12],[22]" depending on your own values.2) Use a nvarchar variable to hold the SQL DECLARE @Sql nvarchar(1000)SET @Sql = 'SELECT * FROM @Test PIVOT (COUNT(LoggedIn) FOR UserID IN (' + @InPart + ')) AS p' 3) And, using the system stored procedure "sp_executesql", execute the SQL that is in the nvarchar variable EXEC sp_executesql @Sql
  22. jesh

    T-SQL PIVOT

    I'm in the process of learning about T-SQL and have, just today, discovered the PIVOT keyword. I'm running SQL Server 2005 and have been able to create a pivot table using the PIVOT keyword when I know what the column names should be in advance. Suppose, for a rather stupid example, that I had a table which created a record when a user logs into a website. Something like this: DECLARE @Test TABLE( UserID int, Date datetime, LoggedIn tinyint)INSERT INTO @Test VALUES (1,'01-22-2007',1);INSERT INTO @Test VALUES (2,'01-22-2007',1);INSERT INTO @Test VALUES (1,'01-23-2007',1);INSERT INTO @Test VALUES (1,'01-23-2007',1);INSERT INTO @Test VALUES (1,'01-24-2007',1);INSERT INTO @Test VALUES (2,'01-24-2007',1);INSERT INTO @Test VALUES (1,'01-25-2007',1);INSERT INTO @Test VALUES (1,'01-26-2007',1); I can create a Pivot table which tells me how many times certain users log into the site each day like this: SELECT * FROM @TestPIVOT(COUNT(LoggedIn) FOR UserID IN ([1],[2])) AS p This produces the following results: Date 1 2----------------------------------2007-01-22 1 12007-01-23 2 02007-01-24 1 12007-01-25 1 02007-01-26 1 0 However, the only way I can do this is if I type in the UserIDs in that IN clause ("[1],[2]"). Does anyone know if it is possible to make this more dynamic?This does not work: SELECT * FROM @TestPIVOT(COUNT(LoggedIn) FOR UserID IN (SELECT DISTINCT UserID FROM @Test)) AS p Error: "Incorrect syntax near the keyword 'SELECT'."
  23. jesh

    Print Preview

    window.print() will act the same as if the user had clicked the print button in their browser. There isn't, as far as I am aware, any way to display the print preview window that appears as part of the browser.If you use a css file for print: <link rel="stylesheet" type="text/css" media="print" href="print.css" /> You could then build a second page which uses that stylesheet (with media="all") to render the page and the users would be able to see what the page would look like when it was printed. Margins and paper settings will, however, differ on different browsers.
  24. The DOM property to enable/diasable a form input is ".disabled" and the DOM method to submit a form is ".submit()".You could have a function similar to this: function enableElements(formObj){ var formElements = formObj.elements; for(var i = 0; i < formElements.length; i++) { formElements[i].disabled = false; }} And you could call it on the submit event of your form: <form id="myForm" action="myAction.php" method="POST" onsubmit="enableElements(this);"> EDIT: Alternatively, you could store the data in hidden inputs. Both of these methods, however, can be circumvented by savvy users. The most secure method would be to check the fields on the server when the form was submitted. If there are values in the database for certain fields, then the values submitted with the form could be ignored.
  25. The immediate solution is to set up a web server and load the file from it rather than directly from the file system. For example, set up a web server so that the file is loaded from http://localhost/thefile.html rather than c:\files\thefile.html.
×
×
  • Create New...