Jump to content

Adam

Moderators
  • Posts

    5,717
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Adam

  1. Sorry, back tracking a little... Have any examples of this? I've never seen it. They must have been using a plug-in that connects to a PHP script or something, because JavaScript simply can't query a database directly, and jQuery certainly doesn't natively support it as a result.
  2. This is a very common question with lots of solutions you can find through Google. If you run into any problems implementing one of them though, I'll be happy to help...
  3. There's the CSS page-break-before property.
  4. Due to the way LOBs are stored internally, you can't return them like normal data types. Have a read of this article, it looks to explain the process pretty well.
  5. There's no such function unfortunately, probably because the structure of an XML document can vary so much. What you could do is get all the children of the first structure's root element, and append them to the root element of the second structure's (or vice-versa).
  6. Just tested this in FF4 and found an issue. It's caused by the alert() call in the moveLeft() and moveRight() functions, taking focus from the document so that you have to click on the page before the event will trigger again. When you actually add the proper animation code without an alert() call though, that won't be a problem.
  7. You just need to attach the events (click on the buttons, and keyup on the document) to call the same function which performs the animation: $(document).ready(function() { // Assign the left/right button click events $('#leftButton').click(moveLeft); $('#rightButton').click(moveRight); // Assign the key press event to the document $(document).keyup(function(event) { // IE doesn't support event.which if (event.which == null) { var key = event.keyCode; } else { var key = event.which; } // 37 = left arrow if (key == 37) { moveLeft(); // 39 = right arrow } else if (key == 39) { moveRight(); } // Prevent normal event action (possible scrolling // if there's a horizontal scroll bar) event.preventDefault(); }); }); function moveLeft() { alert('moving left...'); } function moveRight() { alert('moving right...'); } That will event work with IE6! Note I used the "keyup" event instead of "keypress" by the way, which is because certain keys are only supported in certain events. Working with key detection is quite a nightmare sometimes in JavaScript! Also for that to work you would need to assign the left/right buttons an ID of "leftButton" and "rightButton" - but obviously you change those.
  8. You're not providing enough information. Show us the code where you retrieve the data via PHP, and where it's integrated into the JavaScript. Showing a few random statements mixed with PHP doesn't really help...
  9. The event.explicitOriginalTarget object contains the object which triggered the original event. So as an example for the first step of what you want to achieve: <script type="text/javascript"> window.onload = function() { document.requestform.onsubmit = function(event) { alert('Name: ' + event.explicitOriginalTarget.name); alert('Value: ' + event.explicitOriginalTarget.value); return false; } } </script> <form name="requestform"> <input type="submit" name="ButtonName1" value="Button Value 1" /> <input type="submit" name="ButtonName2" value="Button Value 2" /> </form>
  10. In chart.php you're assigning the values like: $arr[] = array("valor{$i}" => $row[valor]); So you would end up with keys like "valor0", "valor1", "valor2", etc. In the JavaScript, once the array has been converted to JSON and passed back, you're then trying to access it like: json[' + i + '].valor(' + i + '+1) Which for example would be "json[0].valor(0+1)", "json[1].valor(1+1)", etc. None of this adds up.. Try this as the JavaScript loop: for (x in json) { var valor = eval('json[' + x + '].valor' + x); msg[] = parseFloat(valor); }
  11. Change: $msg[i] = parseFloat(eval('json[' + i + '].valor(' + i + '+1)')); To: msg[i] = parseFloat(eval('json[' + i + '].valor(' + i + '+1)'));
  12. I'm only picking at random as you've given a very vague description of the problem.. var msg = []; for (i = 0; i < 2; i++) { $msg[i] = parseFloat(eval('json[' + i + '].valor(' + i + '+1)')); i++; You're defining the array as var msg, but then trying to add to it as $msg - are you confusing your PHP, JS and jQuery? Variable names in JS can start with a $, but in your case you're just calling it msg...
  13. Well.. Where is $msg defined? I can see where you're assigning it in the AJAX success method, but what about in the JSON string I'm assuming the chart.php file returns?
  14. Newer browsers don't need that JavaScript for the menus to work - the CSS does it all. By attaching the event using "attachEvent", which is only supported in IE (<= 6/7?), the JavaScript is only triggered in browsers which need it. When IE6/7 is triggering this code however, you have a typo in the function name. It should be: Also JavaScript is case-sensitive, and in your call to document.getElementByID you have "ID", which should be "Id". by the way, those styles and JavaScript should be within the <head></head> tags of your document.
  15. An easy solution to this is to convert the characters to HTML entities, using the htmlentities function. You can then use html_entity_decode to decode them, if needed. If you're outputting to a web page it's better to leave them as HTML entities however.
  16. Personally I'd say learn JavaScript. jQuery is obviously written in JavaScript, and knocking how the language works is always beneficial for better code. There's also aspects of JavaScript jQuery doesn't touch; such as strings, dates and numbers. These core objects, even in jQuery, are still accessed and manipulated in the same way. Little things like that, and of course knowing the constructs and abilities of the language, I think make it worthwhile.
  17. Where exactly do you want the text to appear? Can you show the mark-up you're working with, and point out the element(s) that should have the text?
  18. Yeah.. You'd need an LDAP server installed and set-up with the required users' details replicated as LDAP entries, that you can then form a request to validate the login. Be aware this method would require you to maintain the LDAP server whenever someone changes their password or username. The point I was getting at was that there's no way of retrieving the actual, real-time Windows username; though thorpe you were more constructive in your answer.
  19. How about the manual?
  20. How would you validate the details are correct?
  21. Don't forget version control, vital to any project where there's multiple developers. Not only to provide an up to date branch of the code base for each developer to work on separately, but to cleanly merge in new developments as well. You should also have one developer code review another's work - this helps prevent bugs and issues later down the line, and can often lead to better quality code. Version control makes this process a lot easier too.
  22. There is a way to retrieve the Window's username using VBScript, but that doesn't work when accessed through the HTTP protocol or for any other browser than IE. You mentioned it's an Intranet site though, so I guess that's ruled out.
  23. If your data contains slashes you should look at how they're getting in originally, not how to remove them as you're getting it out. If you correctly escape the data as you insert it, there shouldn't be slashes within it. It's possible your server has magic quotes enabled and you're double escaping the data or something, in which case I would look at trying to disable it. You should always use the DBMS' built-in function to escape data; if you're using MySQL then it would be the mysql_real_escape_string function. That will escape certain characters within the string for insertion, but as inserted they will simply escape each character's special meaning and not actually get inserted themselves - which is what should happen. Then when you extract the data, you won't need to use stripslashes() or anything (although a different type of escaping should be done to prevent XSS - look at htmlentities and htmlspecialchars).
  24. Not possible with JavaScript, PHP or any other web-technology. It would be a security risk for websites to be able to retrieve the user's personal information such as that.
  25. Takes a function as a parameter and assigns it to the object's "onclose_func" property. There is very little more we can tell you about this based on that, as there is no standard "onclose_func" property. This code is completely custom written... As Omirion says, show the rest of it.
×
×
  • 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.