Jump to content

MadnessRed

Members
  • Posts

    262
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

MadnessRed's Achievements

Regular Member

Regular Member (3/5)

0

Reputation

  1. Hi, for some reason my canvas is only drawing some of the images I expect. test.html <html> <head> <title>Canvas Test</title> <!-- FOR IE --> <!--[if IE]><script src="scripts/excanvas.js"></script><![endif]--> <script type="text/javascript" src="scripts/canvas.js" ></script> </head> <body onload="load_treeview();"> <div id="xml_dump" style="display:none;"></div> <canvas id="treeview" width="200" height="200"> <p>Your browser doesn't support canvas.</p> </canvas> </body> </html> canvas.js function load_treeview(){ //Load the canvas var drawingCanvas = document.getElementById('treeview'); // Check the element is in the DOM and the browser supports canvas if(drawingCanvas.getContext) { // Initaliase a 2-dimensional drawing context var context = drawingCanvas.getContext('2d'); //Load the xmlhttp if (window.XMLHttpRequest){ xmlhttp=new XMLHttpRequest(); } else{ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); alert('Please upgrade your browser, this script is designed to be used on HTML complient browsers.');} //Get the xml file. xmlhttp.open("GET","tree.xml",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; //Place position(xmlDoc.getElementsByTagName("img")[0], context, 0, 0, []); //Otherwise complain }else{ alert('Couldn\'t load canvas, please use a HTML5 complient browser.'); } } function position(xml, context, xpos, ypos, images){ //Get the children var children = xml.childNodes; //Total width var width = 0; //Are there children? if(children.length > 0){ //Loop through children for (i = 0; i < children.length; i++){ //If we have an image if(children[i].tagName == 'img'){ //Add the width of the image width += position(children[i], context, xpos+width, ypos+100, images); } } } //No children, just add the width of ourself then. else{ //If there are no children, set the width to 1 image. width += 100; } //Add image into the array k = images.length; images.push(new Image()); alert('Drawing image[' + k + ']: ' + xml.getAttribute("src") + ' at ' + (xpos - ((80 - width) / 2)) + ', ' + (ypos - -10)); //Draw image images[k].onload = function() { context.drawImage(images[k], (xpos - ((80 - width) / 2)), (ypos - -10), 80, 80); } images[k].src = xml.getAttribute("src"); //Return the width of this item return width; } tree.xml <?xml version="1.0" ?> <tree> <img src="./img/1.jpg" border="#FF0000;" label="0"> <img src="./img/2.jpg" border="#FF0000;" lineout="#FF0000;" label="0/4"> <img src="./img/3.jpg" border="#00FF00;" lineout="#00FF00;" label="3/2"></img> </img> <img src="./img/3.jpg" border="#00FF00;" lineout="#FF0000;" label="3/5"></img> </img> </tree> When I run it I get, this: Firefox: Alert: Drawing image[0]: ./img/3.jpg at 10, 210 #Nothing happens Alert: Drawing image[1]: ./img/2.jpg at 10, 110 #Nothing happens Alert: Drawing image[2]: ./img/1.jpg at 10, 10 #img1 draws at 10, 10 Chrome: Alert: Drawing image[0]: ./img/3.jpg at 10, 210 #Nothing happens Alert: Drawing image[1]: ./img/2.jpg at 10, 110 #Nothing happens Alert: Drawing image[2]: ./img/1.jpg at 10, 10 #img1 draws twice at 10, 10 and at 10,110 If however, I remove the alert, it draws the img1.jpg twice, once where I would expect the img2.jpg to be. So basically, why is the second img3.jpg ignored, and why are neither of the showing? Even though it has got to the line where they are drawn. I'm very confused by this, any help would be great.
  2. If a problem that a script is not colouring a number as expected. I have this if(a >= b){ colour = 1 }else{ alert(a + '<' + b); } however, it returns an alert saying 12349414.9041 < 15000 Any idea as to why this might be happening? actually i think I have worked it out, it is reading teh vaues as string and < refers to its alphabetic position, eg 'aa' < 'z' '11' < '9' I have done a parseFloat and that sorted it.
  3. I have sorted it, mysql didn't like multiple queries. I exploded the string by ; and ran each query separately and its fine now. Thanks for the help though, and also are there any better ways of doing this as I know exploding by ; is crude.
  4. Firstly here is the bit of my code which runs the query. //Log $handle = @fopen("./install/sql.log", 'w'); fwrite($handle, $sql); fclose($handle); //Import @mysql_query($sql) or die('5 - '.mysql_error()); And i get the output Then if I open sql.log, copy and paste the code from there into php my admin. I don't understand how phpMyAdmin is working code that php won't, when pma itself is php. The code is a set of tables exported from phpmyadmin. Any help would be great.
  5. I think I worked it out. it was reading it as a string and that mean it was textually less than not numerically less that. Like if you sort alphanumerically 1-9,a-z, then 123 < 7 in the same wasy that abc < g. So to fix I multiplied both by 1 which made them into numbers
  6. ok, thats because browser like opening in a new tab, not a new window, i found a way though... <input value="Play All" type="button" onclick="window.open(\'test.php?genre='.$genre_select.'\',\'_blank\',\'location=1,width=280,height=500\');" />
  7. jsut reading through breifly <input type="submit" value="Close" onClick="return check('updaterecord', this.name)"/> this.name is the name of the submit button which in this case is undefined. I will edit post when I have read though the rest of the script. -------------- to stop the form submitting try adding "return false;" to the function <input type="submit" value="Close" onClick="return check('updaterecord', this.name); return false;"/> not sure if it works no forms but its how you stop links in hrefs - worth a try though. -------------- If all you want is a message if the feild is not filled it. Just have a check in the submit button. <input type="button" value="Close" onClick="if(document.updaterecord.close_reason == ''){ alert('Specify action done for this notification'); }else{ document.updaterecord.submit(); }"/>
  8. <input value="Play All" type="button" onclick="window.open(\'test.php?genre='.$genre_select.'\',\'_blank\');" /> does that work?
  9. so you want to click the button and have a window open, and thats it?
  10. I have this code... if(a > b){ //Do some stuff }else{ alert(a + ' < ' + b); } And when I run it, I get this in the alert. Could someone please tell me why that this is the case, as 13941 is clearly greater than 892
  11. so you want the submit button to submit the form, and then open up a new window? if so could you not put the new winfow into the onload of whatever page the form submits to? eg <body onload="window.open (this.href,'mywindow','location=1,status=1,scrollbars=1,width=280,height=500');">
  12. I think the function is window.open onclick="window.open (this.href, "mywindow","location=1,status=1,scrollbars=1, width=280,height=500");" does that work?
  13. I would like to update a table and read from it in 1 go if that is possible, something like $qry = mysql_query("UPDATE AND SELECT FROM `table` SET `group` = 0 WHERE `group` = '$group' ;"); $affected_members = array(); while($row = mysql_fetch_assoc($qry)){ $affected_members[] = $row['id'] ; } or mysql_query("UPDATE `table` SET `group` = 0 WHERE `group` = '$group' ;"); $affacted_members = mysql_affected_ids(); Is there a way to do this, or will I need 2 queries?
  14. try <div id="wb_Shape2" style="position: absolute; top: -94px; left: -15px; height: 500px; width: 791px; z-index: -1;" align="center"> best fix I can thin of. for now, its a very odd way of doing things you have there.
×
×
  • 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.