Jump to content

chronister

Members
  • Posts

    1,438
  • Joined

  • Last visited

Everything posted by chronister

  1. Hi Folks... Hope everyone is doing well today! I have researched this and cannot determine how to do this. Any help here would be appreciated. I have a div area that shows a set of images pulled from a directory. I have a dblClick event working on a label around them for the first load that changes the src of another element to the src of the clicked image (edit in place system for website) and goes away so the page can be saved with the new image. When I upload a new image via ajax and then refresh this area to display the newly uploaded file, my dblClick event no longer works. I remember seeing this has to do with explicitly binding the click event to the dynamically created elements. I cannot find any information on how to bind a dblClick event to my img elements after I refresh the section. Here is the code I am working with. This is all inside a document ready block just to clarify. This is the dblClick event that gets attached to the label $('.newimageContainer label').on("dblclick",function(e){ // Get the src of the img below the label that was clicked imgSrc = $(this).children("img").attr('src') // Set the src of the prior selected page image to the new src $('.changing').attr("src", imgSrc); // close modal modal.close(); }); Here is the code that does the replacing of data. It is the complete callback inside an ajax function. complete: function(){ // STOP LOADING SPINNER AND DISPLAY MESSAGE $('.msgArea').html('<strong>SUCCESS: File Uploaded</strong>'); // Clear the html inside the image picker $('#imagePickerWrapper').html(''); // reload and load the new set of data into the image picker area $('#imagePickerWrapper').load( "/lib/php/updatePage.php .images" ); } It is after this .load method gets called that my dblClick stops working. If anyone can help, I would appreciate it very much... Here is the HTML block for the image picker area (with the php function call) <div id="imagePickerWrapper"> <span class="images"><?php echo displayUserImages(); ?> </span></div> Thanks, nate
  2. I think I got it.. but what say ye javascript gurus.... Jessica, it was not opening the found / lost main section when the 1st level ul li item was clicked. But the 2nd level li items would show those individual sections. I have changed the jquery and it does work as intended, but I think it could be better. <script> $(function(){ $('#lost_cats, #found_cats, #lost_dogs, #found_dogs').hide(); $("#lost-and-found a").click(function(event) { var href = $(this).attr('href'); $('#lost_cats, #found_cats, #lost_dogs, #found_dogs').hide(); $(href).show(); $(href).children().show(); event.preventDefault(); }); }); </script> Not I am not using chrome dev tools or firebug (though I do have it installed.. I think) Is the code here ok or do you have a suggestion to make it better? I think it is probably clumsy.
  3. Hello all, How is everybody doing today?? I am trying to get an unorderd list as trigger to toggle / expand some div's and I am struggling on this. Can someone point me in the right direction? <div id="lost-and-found"> <ul> <li><span><a href="#lost">Lost Animals</a></span> <ul> <li><a href="#lost_cats">Cats</a></li> <li><a href="#lost_dogs">Dogs</a></li> </ul> </li> <li><span><a href="#found">Found Animals</a></span> <ul> <li><a href="#found_cats">Cats</a></li> <li><a href="#found_dogs">Dogs</a></li> </ul> </li> </ul> <div class="clear"> </div> </div> <div id="found"> <div id="found_cats"> <h2>Found Cats</h2> <?php display_lf($found['cat']); ?> </div> <div id="found_dogs"> <h2>Found Dogs</h2> <?php display_lf($found['dog']); ?> </div> </div> <div id="lost"> <div id="lost_cats"> <h2>Lost Cats</h2> <?php display_lf($lost['cat']); ?> </div> <div id="lost_dogs"> <h2>Lost Dogs</h2> <?php display_lf($lost['dog']); ?> </div> </div> <script> $(function(){ $('#lost_cats, #found_cats, #lost_dogs, #found_dogs').hide(); $("#lost-and-found a").click(function(event) { var href = $(this).attr('href'); $('#lost_cats, #found_cats, #lost_dogs, #found_dogs').hide(); $(href).show(); $(this).parent("div").show(); event.preventDefault(); }); }); </script> The ul is 2 buttons (Lost / Found) with Cat and dog under each. I have a div with id of lost and one with found. Inside each, there lost cat, lost dog and found cat, found dog respectively. I am trying to hide all sections initally with jquery and then open the lost / found section or the subsections of lost -> dog, lost -> cat, found ->dog, found -> cat. Any tips / pointers will be appreciated.
  4. Yeah, it appears to be just normal form field processing. You can use the whole mask thing, but I find it annoying when the page dictates what can be entered via javascript. I would just make it so you can accept any time format and then make it the format you want. I disagree with this. At first it makes it easy as the rules are not so tight as to how it is formatted... but if you need to do any kind of query past SELECT this FROM that you may have trouble. When I started, I would store dates and times in a varchar field and it made it easy, until I needed to select dates and times between 2 points, or dates where it falls on a particular day.. Store dates and time as the proper format, it will become easier as time goes.
  5. $image->save('uploadedphotos/'.$picturename.'.jpg'); You have to have the additional periods to properly concatenate the string.
  6. Because with the new video and audio tags, they are not real easy to use. There is no 1 format that works across all browsers and some browsers don't even support them at the moment (I am looking in your direction IE).
  7. Look at the server superglobals. $_SERVER[] ... there are a few that may do what you want.. the one off the top of my head is $_SERVER['PHP_SELF'] As for the video, you will probably have to look into a custom player ( or use HTML 5's video tag (read long and hard about this before you use it)
  8. Use CURL to submit the request behind the scenes. You will need to set up a cron job to run the target PHP script at a particular time and frequency. Nathan
  9. <?php for($x = 0; $x < 10; $x++) { echo "hello"; sleep(10); ob_flush; flush(); } ?> This will stop the infinite loop and only allow this to run 10 times.
  10. Yeah, to give you some code to get you started would be difficult because I have no idea what you have already. If you have done something similar for registration, meaning the generate a hash and email it and validate it on confirmation, then you have the process. Just do it again for this system.
  11. Typically, passwords are hashed using a one way encryption. I don't use any "recover" lost passwords. I reset them. You generate a hash string and store it in the database with their user account after verifying their username and email address. Then you send an email to them with that string as a URL parameter. They click the link and it comes back to your site which validates the hash string and allows them to reset the password. You can use the security question to validate them in the same steps as the username and email combination. Nate
  12. Yeah, those are both better options if the end users are knowledgeable of these things. But the last project I completed which I implemented the mentioned upload script, the user is not savvy enough to zip files up and upload that single zip file nor do they have any idea what FTP is, how to use it or care to learn. I attempted to do a zip file upload script before and had trouble getting the individual file names. That was on PHP 4, I know that PHP 5 has some better zip handling functions.
  13. Just by way of how HTML forms work, they will not allow multiple files to be uploaded at one time. That is just the HTML specs. The only way to get around it is to use a Flash based uploader (thats what Gmail uses) or something similar. I just implemented a multiple file upload using a jquery based script found at http://valums.com/ajax-upload/ It works great and does not rely on flash.
  14. Yeah, CSS is what you are looking for. I build most all of my sites as fixed width sites. I currently build for a max width of 960px. That will ensure that anyone using 1024x768 resolution will not have to scroll side to side. Anyone using less than that is a small enough group (for my targets anyway) that I am not concerned.
  15. I know but i need to meet a deadline for tonight. LOL... I love it when folks are all like "I have a deadline to meet and don't know what I am doing.... save me". I mean I am not going to tell someone I will rebuild their car by tomorrow night, knowing full well I am not a mechanic. too funny. Folks need to fail and learn not to oversell their abilities rather than having others bail them out. Not trying to be a dick or anything, but your deadline is of no concern to the folks who donate their time for free on here.
  16. Remember, pretty well anything you can do with Javascript can be done with PHP. Happy Learning
  17. It just seems ultra redundant. If you look at my last post... your trying to concatenate to a variable that does not exist on the first time round. Programming logic needs to have a variable declared before it can reference it. You can't really do $x + $y if $x does not exist. Any programming language will have an issue trying to use something that is not declared.
  18. Ohhhh.. ok.. that makes sense... can't concatenate to a var that don't exist. I have always heard that it is "good coding" to declare a var before you assign a value to it. I thought I had gotten notices for this crap before.... must have been some other stupid mistake Thanks, nate
  19. I don't understand why people use double quotes and escape the hell out of them when you can simply use a single quote which is a literal string (little performance gain since the PHP parser does not look for variables in them), and concatenate things.... $url= '<SCRIPT LANGUAGE="javascript"> var url; var email = "'.$email.'"; function emailsplit () { var userid = email.split("@"); var url = userid[0]; var imgid = "http://my.snu.edu/images/idpictures/" + url +"-S.jpg"; return url; } document.write(emailsplit()); </script>'; $img[]= 'http://my.snu.edu/images/idpictures/'.$url.'-S.jpg'; Do you realize that the $url var right before -S.jpg, is going to contain the $url var which you declared... which is the entire script block above??? So it basically becomes $img[] = 'http://my.snu.edu/images/idpictures/<SCRIPT LANGUAGE="javascript"> var url; var email = "'.$email.'"; function emailsplit () { var userid = email.split("@"); var url = userid[0]; var imgid = "http://my.snu.edu/images/idpictures/" + url +"-S.jpg"; return url; } document.write(emailsplit()); </script>-S.jpg'; That is not exactly right, but the $url var in the $img[] array is not using the url var inside your script. Javascript is executed on the client side, and PHP is executed on the server... so the PHP is done by the time this javascript even has a chance to run. Unless I missed something here, you should go back to the drawing board on the logic of this code. Nate
  20. I have always wondered why this is. PHP is my first and only programming language, so I am pretty green when it comes to programming patterns, standards and other best practice type stuff. So could you explain why $somevar = 'foo'; will throw a Notice, but $somevar = ''; $somevar = 'foo'; will be accepted. I guess I am not clear on why setting the var to an empty string first is any different than setting it to an actual value. Thanks, nate
  21. I have used $_SERVER['HTTP_HOST']... as in if($_SERVER['HTTP_HOST'] == 'localhost'){ // local host code }else{ // live server code } To the best of my knowledge, these server vars are not immune to modification... so I don't know what the "correct / safe" way is to do this.
  22. I am creating an audio object like this... audio = new Audio(); audio.setAttribute("src", '/lib/audio/'+audio_source+'.mp3'); audio.setAttribute("src", '/lib/audio/'+audio_source+'.ogg'); This works fine, so how would I delete this object (stop playing the audio). I need to either completely stop the audio and destroy this object, or to stop audio and create a new audio object depending on what a user clicks. Any help would be appreciated. nate
  23. Well I figured it out. For the last 4 or 5 questions I posted on here, I got no response from really anyone. So for anyone who might be helped by my solution, an event has to fire to bring this object back to a state where the currentTime property can be set. Nate
  24. No, createMenu is not a built in function, it is created right where you see it at. function createMenu($db, $ulClass = false){ <-- This is the line that is creating this function. The $ulClass = false is an optional parameter to specify a specific class for the un-ordered list that is created. Anytime you create a function, you will typically have parameters that are passed into it. Some of those parameters are optional. By setting $ulClass to false in the function creation, it ensures that the variable is dealt with regardless if I pass a class name into it or not. I don't have proper code in there to handle errors if the $db class handle is not passed, but this code is for me and I will ensure that I pass that into it. Your code is printing empty LI tags because of the way your logic is set. I think it is here <?php do { ?> <li> <?php echo $row_getcategories3['category']; ?> </li> <?php } You have to realize that a do - while loop will do the condition at least once before it hits the while part to determine if it should do it or not. You can try changing <li> <?php echo $row_getcategories3['category']; ?> </li> to if(isset($row_getcategories3['category']){ echo '<li>'.$row_getcategories3['category'].'</li>'; } This checks to see if there is something to display before actually trying to display it. Same principle for the others... if there is not something to show it will probably display an empty LI tag for them. Hope this helps. Nate
  25. I had this same general question no too long ago and got no help on here, so I will help you with what I came up with... it works perfectly and will generate an unlimited nesting un-ordered list. You call the createMenu function to get this done. I am passing in a database class handler ( $db )... you can change it however you want. It then makes calls to the build_menu function and that in turn calls get_child_menu. All in all, it works perfectly, but you may need to adjust things to make it work for you. <?php function createMenu($db, $ulClass = false){ $items = $db->getData("SELECT linkId, displayName, url, parentId FROM navigation ORDER BY sortOrder, parentId, linkId ASC"); while ($row = mysql_fetch_object($items['result'])) { $menu[$row->linkId]['parent'] = $row->parentId; $menu[$row->linkId]['text'] = $row->displayName; $menu[$row->linkId]['link'] = $row->url; } return build_menu($menu, $ulClass); } function build_menu($menu, $ulClass){ $listClass = (isset($ulClass)) ? ' class="'.$ulClass.'"' : ''; $output = "\n".'<ul'.$listClass.'>' . "\n"; // Start menu generation foreach($menu as $linkId => $linkData ) { if (is_array($linkData)){ if($linkData['parent'] == 0 ) { $output .= ' <li class="'.$linkData['class'].'"><a href="'.$linkData['link'].'"><span>'.$linkData['text'].'</span></a>'.get_child_menu($menu, $linkId).'</li>' . "\n"; } } } $output .= '</ul>'."\n"; return $output . "\n\t"; } function get_child_menu($menu, $parentId){ $has_subcats = FALSE; $output = "\n".' <ul>' . "\n"; foreach($menu as $linkId => $linkData){ if ($linkData['parent'] == $parentId ) { $has_subcats = TRUE; $output .= ' <li><a href="'.$linkData['link'].'">'; $output .= $linkData['text']; $output .= '</a>'; $output .= get_child_menu($menu, $linkId); $output .= '</li>' . "\n"; } } $output .= ' </ul>'."\n"; return ( $has_subcats ) ? $output : FALSE; } ?> It is based on the principle of getting the data from the database and returning an array and passing that to the next function. It looks a little cleaner than your existing code. The database is structured like this..... linkId displayName url parentId sortOrder linkId is an auto-incrementing primary key, displayName is what is displayed for the link text, the url is it's href location, the parentId is the parentId of this item and the sortOrder is for specifying sort order. Holler back if you have any questions. Nate
×
×
  • 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.