-
Posts
5,717 -
Joined
-
Last visited
-
Days Won
6
Everything posted by Adam
-
It looks like you're already using a call back to me..?
-
You're on the right track. You need to treat the function like an object (well it is an object) and define the function as a property of the object: this.autosuggest_results = function(info) { That makes it accessible to the outside world, as you're only calling an object's property (which is actually a function). You asked a similar question the other day, but in that case you were trying to access a function within a function, within an object -- try to ignore the fact that a function is actually an object in JavaScript for the moment. You can't do that in the way you were thinking and would have meant a fundamental re-structure of your code (which is why I didn't go into greater details at the time). I'm not about to go into great detail about how JS objects work now either (there's plenty of information on the internet and in books) but consider this example: function ParentObject() { this.level1 = new ChildObject; } function ChildObject() { this.level2 = function() { alert('Calling a function within an object, within an object'); } } var instance = new ParentObject; instance.level1.level2(); That would achieve what you were wanting, but the logic and structure behind it is much different to the code you had. Think about the objects you have available in JS already; "document" is a child object of "window". The DOM tree is built of objects within objects, but they're not one large inherent object, they're broken down into smaller objects. If this is all very puzzling I'd read up on some OO theory before continuing.
-
They've had two actually, this is their third attempt (remember Buzz?) I wonder if they're so persistent so that they can gain the same advertising capabilities as Facebook? With more and more people becoming "aware" of behavioural tracking, and not to mention these ridiculous EU cookie laws next year, Google may be planning for the future..? Looks as though they've got too many users for the time being though so I can't have a play!
-
You mean count how many sessions there are? That's not so simple, as when your code executes you only have access to that specific user's session within the $_SESSION array. Session data by default is stored within individual files within a directory on the server, so counting the files is very inefficient. Since you have users, I'm assuming you also have a users database table to validate their username/password? Extend this table by adding a new column that stores a timestamp of their last activity (last page request). Using this timestamp you can then query for users that have been active in the last 5 minutes or so, and efficiently get an accurate count of active users.
-
Shouldn't you apply it as instructed by the author?
-
I've never heard of it before. Unfortunately I'm not going to sit down and learn how it works for free, as I'm sure most people here will take the same view. You would most certainly get the solution posting in the freelance board though..
-
Javascript Date/Time manipulation on different locales and OSs
Adam replied to stakisko's topic in Javascript Help
Ohh bloody hell. Silly oversight.. I even looked up the valid arguments to pass the constructor! Well, we both live and learn.. -
Javascript Date/Time manipulation on different locales and OSs
Adam replied to stakisko's topic in Javascript Help
Right I'm confused. var laterDate = new Date(1309291823); Does this work (forget passing it a string for now)? If not, do you receive an error? Do you see any output ("Nan:Nan[...]" for example)? What does happen? If you run this as a static value (i.e. replace the dynamic PHP echo with it) does it work then? I've ran the JS with a Unix time stamp myself and it works; and should always work regardless of language given it's an integer. -
You can't, it's out of scope. Only the parent function can call it.
-
Javascript Date/Time manipulation on different locales and OSs
Adam replied to stakisko's topic in Javascript Help
Just testing So back to my other request, can you show what is being passed to the date object by looking at the source when running the code? Need the actual value, not an explanation though. -
Like some of your other file formats in that array, the ZIP format has quite a few different possible MIME types: application/zip application/x-zip application/x-zip-compressed application/octet-stream application/x-compress application/x-compressed multipart/x-zip For this reason, it's better to use the file extension in the actual file name to validate the data type.
-
Newbie with stupid question about DATETIME...I know.
Adam replied to Bminor's topic in PHP Coding Help
Don't worry, everyone's been there. After this line: $registration_date=mysql_result($result,$i,"reg_date"); Add: var_dump($registration_date); That will dump the contents of the variable and tell you the datatype, which should help debug the issue. -
Javascript Date/Time manipulation on different locales and OSs
Adam replied to stakisko's topic in Javascript Help
JavaScript doesn't understand a MySQL time stamp. As I was suggesting, pass JavaScript a Unix time stamp (integer value e.g. 1309388400) that cuts out any language barriers. -
Javascript Date/Time manipulation on different locales and OSs
Adam replied to stakisko's topic in Javascript Help
I'm having a little trouble understanding some of the things you're saying. "Passing the timestamp the code" - I'm guessing you mean passing the code the timestamp, but what code are you referring to? At what point in this process (which call, which language, etc) is the failure happening? -
Why don't you use a JOIN in the query to return the data from each table as one set?
-
Javascript Date/Time manipulation on different locales and OSs
Adam replied to stakisko's topic in Javascript Help
If you view the source when the code is running, what's the argument passed to the Date object (in an environment where it doesn't work)? -
Javascript Date/Time manipulation on different locales and OSs
Adam replied to stakisko's topic in Javascript Help
Do you have an example available online? Would make debugging a lot easier. -
Javascript Date/Time manipulation on different locales and OSs
Adam replied to stakisko's topic in Javascript Help
Ah, use a Unix timestamp. Basically the milliseconds since 01/01/1970, which both PHP and JS understand regardless of OS. -
Both jQuery and prototype use '$' as a short-cut within their frameworks, and so you get conflicts when trying to combine the two. I don't know of an equivalent for Prototype, but jQuery has a noConflict() function you can use to prevent it. Given Prototype is only used for that one solution though, it wouldn't really make sense to do that. Have you looked at a jQuery equivalent for Comet support?
-
Javascript Date/Time manipulation on different locales and OSs
Adam replied to stakisko's topic in Javascript Help
What's the actual problem? -
Can you show us a sample of the JSON data you're working with?
-
Your browser may have cached the image not existing, or the server itself. If it happens with another image, try adding "?foo" to the end of the address and see if that works.
-
Is "tag" a plug-in? It's certainly not standard jQuery.
-
You can access the select box value through the DOM tree using: document.formName.selectName.value You'll need to assign the "onchange" event to the select box too, so that you can capture the value as they change it. One thing to note is that you're not correctly assigning the value of each option; you should use the "value" attribute. Browsers default to using the option text instead though, so you're code will still work.