unplugged_web
-
Posts
897 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by unplugged_web
-
-
Unfortunately I have no control over how the script is printed at all. I just have a url that I need to get the information from.Can you change how it prints that? That is not the easiest string to parse. It would be a lot easier to put that in a format to start with that Javascript can use immediately. -
Sorry I wasn't very clear, it's a string. When I open the console there's nothing to expand. This is exactly what I get:
They're sorted by Name, Initial Value, Total Amount. I need to get the Total Amount depending on what the Name are Initial Values are. So for example I want to Total Amount of Jo when the Initial Value is 0.50, but not when it's 0var currents="[Jo,0,1250.21][ian,0.10,2578.30][Fred,2.00,249.25][sue,0.30,1157.56][Chris,0.60,0.15][John,3.00,4742.60][Carl,0.50,0.00][Amanda,0.50,1356.89][Zoe,0.50,549.28][Jo,0.50,0.00][Jen,0.50,0.00][Jo,1.00,288.27][Tracey,1.00,1499.20][Colin,1.00,0.00][simon,1.00,0.00][William,1.00,0.00][Ty,5.00,4872.86][Red,2.00,249.27][ian,2.00,1023.41][Jeff,2.00,0.00][Kevin,2.00,0.00][Carol,2.00,0.00]"; function currentValues() { $("#currentinfo").html(currents); } -
When I go to the url that returns that, that's exactly what I get. I can't give the url though as it's password protectedIs that actually a string like you showed or does it return an array? -
I've got a function called currentValues() that gives the information I need in the following format [Name, Initial Value, Total Amount]. An example of what I get is: var currents="[Jo,0,1250.21][ian,10,2555.11][Fred,2,186.36][sue,0.30,1157.56]"; function currentValues() { $("#currentinfo").html(current s); } But I don't know how to get it so that I can display just the Total Amount of say Jo. I don't even know where to start so would be grateful for any pointers.
-
I've cracked it - I just created a page that stored the embedded code and then called that in the link instead
-
I've been working on a rebuild for a while, but am stuck on loading embedded video. It worked on the old site, but I don't know how to get it to work on the new site. All of the embedded code is stored in a database and I'm trying to load it when somebody clicks a thumbnail. The code that worked on the old site was this:
<script type="text/javascript">jQuery(document).ready(function($) {$("#gallery #videos #loader").empty().html('<img src="/css/loader.gif" alt="" />')$('#gallery #videos').load($('ul.thumbs li a:first').attr('href')); $('.thumb').click(function(e){$("#gallery #videos #loader").empty().html('<img src="/css/loader.gif" alt="" />')$('#gallery #videos').load($(this).attr('href'));e.preventDefault();}); });</script>
but as the old site used Cake I don't know how to change this so that it works.The entire code I have is this:
<div class="video view"><div id="thumbs" class="navigation"><ul class="thumbs noscript"><?php include 'includes/db.php'; ?><?php$con = mysql_connect($host,$username,$password);if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db($database, $con);$result = mysql_query("SELECT images.foreign_id, images.filename, videos.embed_code, videos.title, videos.order, videos.artist_id, artists.first_name, artists.last_name, artists.slug as artslug, videos.slug as videoslugFROM images, videos, artistsWHERE videos.artist_id = $id AND images.foreign_id = videos.id AND artists.id = $id AND images.class = 'Video'GROUP BY images.filenameORDER BY videos.order ASC");while($row = mysql_fetch_array($result)){echo "<li><a href=\"/video.php?id=$id&video={$row['videoslug']}\" class=\"thumb\"><img src=\"/uploads/image/filename/thumb/thumbnailbig/". $row['filename'] . "\" alt=\"{$row['first_name']} {$row['last_name']} {$row['title']}\" title=\"{$row['first_name']} {$row['last_name']} {$row['title']}\" /></a></li>";}mysql_close($con);?></ul></div><div id="gallery" class="content"><div id="videos"><div id="loader"></div></div> </div></div> <script type="text/javascript">jQuery(document).ready(function($) {$("#gallery #videos #loader").empty().html('<img src="/css/loader.gif" alt="" />')$('#gallery #videos').load($('ul.thumbs li a:first').attr('href')); $('.thumb').click(function(e){$("#gallery #videos #loader").empty().html('<img src="/css/loader.gif" alt="" />')$('#gallery #videos').load($(this).attr('href'));e.preventDefault();}); });
It loads the first video, but when I click to load a new video it just reloaded the first one. I'd be grateful for any help as I'm not sure how to fix this and the client is on my back to get this fixed. Thanks in advance
-
Just in case anybody else gets stuck with this, I changed the code to below:
<?phpinclude '../includes/db.php'; $images[] = $_POST['images'];$i = 0;if(!empty($images[0])){foreach($images as $value) {foreach($value as $row){$i++;if($row != 'tHeader'){$con = mysql_connect($host,$username,$password);if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db($database, $con);mysql_query("UPDATE `images` SET `order`='$i' WHERE `id`='$row'");mysql_close($con);}}}}?>
and it now works perfectly.
-
I'm usingIt should be that? Are you going to verify what it actually is or just work on assumptions?
to check the results. This is the entire code I'm using for the drag and drop:alert($.tableDnD.serialize());<script language="Javascript">$(document).ready(function() { // Initialise the table$('#images').tableDnD({onDragClass: "drag",onDrop: function(table, row) { alert($.tableDnD.serialize()); $.ajax({type: "POST",url: "http:/www.domain.com/new_site/admin/ajaxtest.php",data: "" + $.tableDnD.serialize(),success: function(html){}});}});}); </script>
-
Post should be the variables from each row. If I move a row then the " alert($.tableDnD.serialize());" line brings up a dialog box with the new order. This is what the dialog box shows:That's fine, but that doesn't tell me what is actually in $_POST. You need to verify that first.Result of $.tableDnD.serialise() is images[]=12.2&images[]=22.1&images[]=3.3&images[]=13.4&images[]=8.5&images[]=7.6 -
Images is the table id, each row in the table has it's own id (which corresponds to the id in the database), I'm trying to automatically update the order after somebody has changed it.Is there actually something in $_POST called "images"? You can use your browser's developer tools to verify that. Otherwise, what you're telling PHP to do is to push a new item onto the end of the array $images, but $images isn't an array yet, you haven't declared it to be anything. I'm not sure why you're trying to push an item onto the array if it's the only item though, why not just set it to $images? You can output whatever you want in that PHP script to help you debug it, and you can see the response from PHP also in your browser's developer tools to help you figure out what it's doing. -
I've found this drag and drop script and it's brilliant but I can't seem to get it to update the results in the database. I've got this on the page:
<script language="Javascript">$(document).ready(function() { // Initialise the table$('#images').tableDnD({onDragClass: "drag",onDrop: function(table, row) { alert($.tableDnD.serialize());$.ajax({type: "POST",url: "http:/www.domain.com/new_site/admin/ajaxtest.php",data: "" + $.tableDnD.serialize(),success: function(html){}});}});}); </script>
the alert box does give the correct values, but when I call the ajaxtest.php page nothing happens.The ajaxtest.php page has this:
<?phpinclude '../includes/db.php';$images[] = $_POST['images'];$i = 0;if(!empty($images[0])){foreach($images as $value) {foreach($value as $row){$i++;if($row != 'tHeader'){$this->Image->set('id', $row);$this->Image->set('order', $i);$this->Image->save();}}}}$con = mysql_connect($host,$username,$password);if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db($database, $con);$sql= sprintf("UPDATE `images` SET `order`='$i' WHERE `id`='$row'");if (!mysql_query($sql,$con))mysql_close($con)?>
I'm pretty sure the problem is with the $images[] = $_POST['images']; but of code, but I'm not sure exactly where.
-
Sorry I think I just had a dumb moment, of course it is!
-
Brilliant thank you, I copied the script from the website so I must have missed that. It now works where it creates a thumbnail of what ever I select! Fantastic. One question though the image source says the url instead of the filename. How do I change that name and save it to a folder? Thanks for your help.Which elements is this supposed to target:function updateCoords(c){$('#CropX').val(c.x);$('#CropY').val(c.y);$('#CropW').val(c.w);$('#CropH').val(c.h);};
-
Yep it's definitely a jpeg, I just checked the file info and it says it's a Adobe Photoshop jpeg. I'm not sure what you mean about wrong IDs thoughIs the image actually a JPEG image? Are the coordinates correct? It looks like you might be using the wrong IDs for those elements. -
Yep it's all correct, but I just get a black image :(If I remove the first part of the path I get this error:Does that mean that you have verified that the form is submitting the correct filename, that the full path in PHP is correct, and that the file exists? Are you just assuming all of that is correct? If you're getting a blank image it sounds like the file you're trying to open doesn't exist.
but if I have the full path then the image is just black rather than showing the part of the image I've tried to cropWarning: imagecreatefromjpeg(/uploads/image/filename/46.jpg) [function.imagecreatefromjpeg]: failed to open stream: No such file or directory in /home/user/domain.com/app/webroot/new_site/admin/thumbnail_test.php on line 21 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/user/domain.com/app/webroot/new_site/admin/thumbnail_test.php on line 25ÿØÿàJFIFÿþ -
I tried using the same filename as the image itself, but I had to use the full path for it because I got errors otherwise.Is the correct filename being submitted by the form?
Oops, I didn't notice that, I've removed that but it's still not working. If it helps I've switched on errors but none are shown. I wondered if it was something to do with the gd library but the site has just been moved to a server with the latest version so I guess that's not it?you one to many open script tags<script type="text/javascript"><script language="Javascript"> remove<script language="Javascript"> as language="Javascript" is never used these days. -
I came across this image crop script which is great and looks like it does exactly what I want it to do, but I'm having a lot of problems getting it to work. I've searched for a solution and although other people are having the same problem nobody seems to have a solution so I'd be grateful for any help please. I can select the area I want to 'crop' but when I click the Crop Image button I just get black thumbnail. I've checked I've got the most up-to-date version of jquery as well as the jcrop script. This is the code I've got:
<?phpsession_start();if (!empty ($_SESSION['loggedin']) ) {$_SERVER['PHP_SELF'];} else { header("location: index.php");}/*** Jcrop image cropping plugin for jQuery* Example cropping script* @copyright 2008-2009 Kelly Hallman* More info: http://deepliquid.com/content/Jcrop_Implementation_Theory.html*/ if ($_SERVER['REQUEST_METHOD'] == 'POST'){$targ_w = $targ_h = 100;$jpeg_quality = 100; $src = $_POST['filename'];$img_r = imagecreatefromjpeg($src);$dst_r = ImageCreateTrueColor( $targ_w, $targ_h ); imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'],$targ_w,$targ_h,$_POST['w'],$_POST['h']); // header('Content-type: image/jpeg');imagejpeg($dst_r,null,$jpeg_quality); exit;} // If not a POST request, display page below: ?>
......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title><?php echo $title; ?></title><meta name="description" content="<?php echo $description; ?>" /><meta name="keywords" content="<?php echo $keywords; ?>" /><base href="<?php echo $base_url; ?>/"><link rel="stylesheet" type="text/css" href="../new_site/css/admin.css" /><link rel="stylesheet" href="../new_site/css/jquery.Jcrop.css" type="text/css" /><script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script><script src="../new_site/js/jquery.Jcrop.js"></script><script type="text/javascript"><script language="Javascript">// Remember to invoke within jQuery(window).load(...)// If you don't, Jcrop may not initialize properlyjQuery(window).load(function(){ jQuery('#cropbox').Jcrop({boxWidth: 700,boxHeight: 700,onSelect: updateCoords,aspectRatio: 1, bgOpacity: 0.2, bgColor: 'black', }); }); function updateCoords(c){$('#CropX').val(c.x);$('#CropY').val(c.y);$('#CropW').val(c.w);$('#CropH').val(c.h);};</script></head><body><div id="container"><div class="artists index"><div id="homepage_thumbs"><div style="float: left; margin-right: 25px; height: 750px;"><img src="/uploads/image/filename/<?php echo $filename ?>" alt="<?php echo $title ?>" id="cropbox" title="<?php echo $title ?>" style="border: 1px solid #CCCCCC;"/></div><input value="Update Image" type="submit" /></form> <!-- This is the form that our event handler fills --><form action="new_site/admin/thumbnail_test.php?id=<?php echo $image_id ?>" method="post" onsubmit="return checkCoords();"><input name="filename" type="hidden" value="/home/user/domain.com/app/webroot/uploads/image/filename/<?php echo $filename ?>"/><input type="hidden" id="x" name="x" /><input type="hidden" id="y" name="y" /><input type="hidden" id="w" name="w" /><input type="hidden" id="h" name="h" /><input type="submit" value="Create Thumbnail" /></form><form method="post" name="delete_Image" style="margin-left: 25px;"><input type="button" onclick="confirmation()" value="Delete Image"></form><br /><br /></div></div> </div> </div> </body></html>
-
Thanks that's exactly what I want to do, except I want it to be saved to the server rather than the desktop.Don E made this site: http://www.cropthis.net Apparently he figured out how to do that. I'm sure it took him quite a bit of work to get there, though. -
That sounds like what I'm after, do you know of any examples/tutorials? I don't really know how to do that myself without any help.Thanks
-
This might not be the place to ask this, but from my understand of the GD library I can do this with PHP. What I want to do is have an image on a page that somebody can select a square area of (any size) and after click to say it's okay that area is saved to the server. If the selected area isn't right then they can move it around or select a different area altogether. I've no idea how to do this and wondered if anybody could help please. I've attached a couple of screen grabs to hopefully show better what I mean.
-
I did try checking mysql_error() but it didn't give me any errors at allinstead of guessing, at least try what's already been suggested to you... -
thank you, I tried that and it worked! Thankstry addin table name in front of itportfolios.order or backward ticks (NOT single quotes) `order` or `portfolios.order` -
I can't change the field name unfortunately, is there another way if do this if that's the problem?field name 'order' confusing SQL, reserved keyword maybe, reading as ORDER BY ORDER -
I tried it without the ORDER BY and it works, as soon as I add that it stops working
Displaying values
in JavaScript
Posted