Jump to content

Adam

Moderators
  • Posts

    5,717
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Adam

  1. Seems to work for me?
  2. Could you elaborate a little more on "something still seems goofy"?
  3. You can use the getElementsByTagName method: var anchors = document.getElementsByTagName('a'); var length = anchors.length; for (i=0; i<length; i++) { // Access link text through: // anchors[i].text }
  4. Judging by the hide() call I'm guessing you're using jQuery? Hopefully so, as the has() method makes this real easy. Give this a try: search_field.onblur = function() { var curr_target = null; var autosuggest = $('#id_of_autosuggest_box'); if (event.toElement) { curr_target = event.toElement; } else if (event.relatedTarget) { curr_target = event.relatedTarget; } if ($(this).has(curr_target).length == 0 && autosuggest.has(curr_target).length == 0) { general_search.hide(); } } Make sure you change the ID.
  5. I believe so, though I only touched AS briefly about four years ago. Looks like the second parameter of the getURL() function allows you to specify the target.
  6. No worries. Though it's generally appropriate in the case of an exception to raise some kind of flag to the user (which can you can handle within the catch block) to notify them if something hasn't happened like they're expecting. That might not be the case this time though.
  7. If he'd asked.. "what's the logically inept way of making this work?" - then yeah, you answered his call.
  8. There's a principle difference between the OP being 'happy' and actually learning something, like these forums are intended to do. You're just teaching people bad habits left, right and centre.
  9. I posted the solution? ------------- document.getElementById("form1").date.value=startForm() function startForm() { document.forms[0].date.value = todayTxt(); } Why do you have the getElementById() call? Why are you setting date.value to the result of the function? The function he posted references the input itself. The only reason your code works, is exactly the same reason in contrast to why it wasn't working previously. The parenthesis on the end cause the execution of the function at that point of assignment, which in itself handles setting the value of the input to the return value of todayTxt(). The entire getElementById() call is redundant - bad JavaScript. You either knew this behaviour was taking place, yet felt the need to create an additional reference to the object and wrapping the call within another function, instead of just calling todayTxt().. Or just tried a few variations and posted the first one you found to work, without any understanding and regardless of whether or not it's teaching people bad habits -- to perhaps try and look like you know something? And as for "the method he was using has been deprecated" - I'm guessing you meant the capital "L", and that you actually meant is in-compliant with XHTML standards? HTML you'll find will support either. But this isn't HTML or XHTML, it's JS, and it's because the methods are case-sensitive that, that wouldn't work. Though that's clearly not what I was getting at anyway... So yeah I stand by my comment.
  10. You need to use a try...catch block to catch the exception, otherwise you'll get the "uncaught exception" fatal error you are doing. try { // code triggering the exception here } catch (Zend_Gdata_App_HttpException $e) { // handle the error here } Note that the code after the catch block will still be executed, so think about that in your handling code. If you want you could specify the generic "Exception $e" instead, which will catch all descendant types of Exception as one. Or you can specify multiple catch blocks to handle certain exceptions differently: try { // code triggering the exception here } catch (Zend_Gdata_App_HttpException $e) { // handle this specific exception here } catch (Exception $e) { // catch all other types of Exception here } I'd strongly recommend reading up on them before hand, as people tend to find them quite confusing at first.
  11. I think you need to do that with ActionScript, don't you?
  12. You're not actually making use of the prevId variable anywhere. Plus, you're only updating the new 'base' if there hasn't been a previous one. Try this: function baseBorder(count) { if (prevId) { document.getElementById(prevId).style.border="none"; } document.getElementById(count).style.border="2px solid #E8272C"; prevId = count; }
  13. To return "Tom": alert(search.users[0][0]);
  14. The JSON specifies a parent "users" object: {"users":[ ... So you need to use search.users.length.
  15. fugix, that is awful JavaScript.
  16. You're passing the array as a string literal - remove the quotes around it.
  17. That will then assign the actual function, not the result of the function.
  18. What's the point in asking why something doesn't work, and then just going with the "that works, it'll do" approach..?
  19. Sorry a bit off-topic here, but just FYI - 'distinct' only returns unique rows in the resulting data set. If each row has a different ID, and you select the ID as part of the statement, then they're not classed as distinct and both will be returned.
  20. Check your database for the entries. If the column's data type isn't long enough, then the MySQL server will truncate it to the right size in order to insert it. When you run the query to check if the event already exists: and fromat='".$curr_events[$curr_event_num]["fromat"]["data"]."' This condition will be evaluating the truncated version to the full length version -- obviously never going to find it.
  21. Change: window.onload = startForm(); To: window.onload = startForm; When binding an event you should assign the function object, not actually call it. In your case you've assigned the result of the function which is executed before the page is loaded (before the form actually exists), to be called after the page is loaded. Hard to explain...
  22. PHP is more than capable of sending/receiving data and handling XML files. Though you've kind of only told us the process you go through at the minute and that you want it to be done in the background. You haven't explained where this XML or CSV files comes from, or what you want to do with them. We need a bit more information...
  23. If you don't need more than 2 columns, and want to encapsulate it within a function, you can use this: function columiseText($str) { // First find the half-way point $length = strlen($str); $target = ceil($length / 2); // Use regex to match the characters from the start of the string to the target // point, and up until the next new-line character. Then also match any subsequent // characters separately... if (preg_match('/^(.{' . $target . '}[^\n]*)(.+)$/s', $str, $matches)) // { // Return matches[1] and matches[2] as an array return array($matches[1], $matches[2]); } return false; } Some usage examples: list($column1, $column2) = columiseText($article); // ... or ... $columns = columiseText($article); // $columns[0] contains column 1 // $columns[1] contains column 2 As I said if you want to support a dynamic number of columns, it's perfectly possible to do so with a bit more work on the function.
  24. Try searching across the application's files for the text. If you still can't find anything, it's very possible that it's stored within the database.
×
×
  • 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.