Jump to content

MadnessRed

Members
  • Posts

    262
  • Joined

  • Last visited

    Never

Everything posted by MadnessRed

  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.
  15. SO you kinda have 2 colums Does this help? http://www.ejeliot.com/blog/61 http://www.ejeliot.com/samples/equal-height-columns/example-4.html
  16. I think you will need php //Max dimentions $maxwidth = 400; $maxheight = 400; $url = 'img/image.jpg'; //Get image info $image = getimagesize('img/image.jpg'); //If image is too wide, change the dimentions if($image[0] > $maxwidth){$image[0] = $maxwidth; $image[1] *= ($maxwidth/$image[0]); } //If image is to heigh, (still, even after resizing the width) change dimentions aswell if($image[1] > $maxheight){$image[1] = $maxheight; $image[0] *= ($maxheight/$image[1]); } And output echo '<img src="'.$url.'" width="'.$image[0].'" height="'.$image[1].'" />';
  17. terminalID, tarminal and bax. Where are you getting that data from? Those all need to be in the html somewhere. If you are doing 3 variables then you have 3 options. Firstly you could use a select which uses javascript to populate 3 other cells. Though i think it would bedone easier in php with explode/implode. eg <form action="<?php echo $PHP_SELF; ?>" method="post"> <table> <tbody> <tr> <td>Kunde</td> <td> <?php $sql = "SELECT name FROM kontakt"; $query = mysql_query ( $sql ); $rowCheck = mysql_num_rows ( $query ); echo "<select name=\"unitSubmit\">"; for($i = 0; $i < $rowCheck; $i ++) { $resultRow = mysql_fetch_array ( $query ); //Now whereever terminal,terminalID and bax should be done here $result = ; echo "<option value=\"".$terminal.",".$terminalID.",".$bax."\">" . $resultRow ['name'] . "</option>"; } echo "</select>"; ?> Then if (isset ( $_POST ['unitSubmit'] )) { $data = explode(",",$_POST ['unitSubmit'],3); //foreach($data as $k => $v){ $data[$k] = mysql_real_escape_string($v); } $sqlInsert = "INSERT INTO terminal VALUES ('" . $data[0] . "','" . $data[1] . "','" . $data[2] . "')"; $sqlQuery = mysql_query ( $sqlInsert ) or die ( error ); } The comment is a quick code to protect against sql injection, I would recommend uncommenting. also could I sugest, slightly off topic but rather than $rowCheck = mysql_num_rows ( $query ); echo "<select>"; for($i = 0; $i < $rowCheck; $i ++) { $resultRow = mysql_fetch_array ( $query ); you do echo "<select>"; while($resultRow = mysql_fetch_array ( $query )) {
  18. Hi, I am having a problem with table row backgrounds. Google chrome resets the background on each <td>. For those who have Chrome you can see what I mean here. http://madnessred.co.cc/anthony/trtest.html Compare that in chrome with firefox or ie. Does anyone know how I can get the Background to be continues in chrome, like it is in FF or IE. atm I am using php to get the user agent string, and if chrome appears in that string it parses a different html string which gives each <td> a background and sets the background poition to give the appearence of a seamless background but this only works with fixed width <td>'s and is a very crude fix. I would like to know a better one if there is one. And also if this is a bug I should report. Thanks Anthony
  19. ok many thanks ps, its not my host, im helping out someone else on their server.
  20. ok many thanks, is it possible to turn them off without access to php.ini
  21. I seem to be loosing variables. Here is my code echo "[".$_SESSION['user']."]<br />"; $user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `Login` = '".$_SESSION['user']."' AND LIMIT 1 ;")); echo "[".$_SESSION['user']."]<br />"; and here is the output. Why does php loose the value of $_SESSION['user'] when I try and use it? [Anthony] []
  22. ok, I solved it, for the sake of anyone else with this problem here is my solution. document.getElementById(n+'.dIi15v').style.left = document.getElementById('xpos'+n).value+'px'; document.getElementById(n+'.dIi15v').style.top = document.getElementById('ypos'+n).value+'px'; for(x = 0; x < dd.elements.length; x++){ if(dd.elements[x].name == n + '.'){ xpos = Math.ceil(document.getElementById('xpos'+n).value * 1 + 8.0); ypos = Math.ceil(document.getElementById('ypos'+n).value * 1 + 8.0); //alert(dd.elements[x].y + '=' + ypos); dd.elements[x].x = xpos; dd.elements[x].y = ypos; dd.elements[x].cssx = xpos; dd.elements[x].cssy = ypos; dd.elements[x].defx = xpos; dd.elements[x].defy = ypos; } } document.getElementById(n+'.dIi15v').style.zIndex = '1';
  23. im getting somewhere, for(x = 0; x < dd.elements.length; x++){ if(dd.elements[x].name == n + '.'){ xpos = Math.ceil(document.getElementById('xpos'+n).value * 1 + 8.0); ypos = Math.ceil(document.getElementById('ypos'+n).value * 1 + 8.0); //alert(dd.elements[x].y + '=' + ypos); dd.elements[x].x = xpos; dd.elements[x].y = ypos; } } Now the clickable thing it on the right square, only problem now is the the peice jump back to the square it was on when you started dragging, then hovers below the mouse.
  24. ok, I am making a live chess page which allows 2 users to play chess over the internet. I am using the walterzorn drag drop library to allo wmovement of the peices. When I user moves a peice the script detects the movement and sends the movement to the game via ajax and the game registers the move. And if its legal adds it to the database. Now when the move is made the moves in the database is increased by one, an simple ajax script which runs every 0.5 seconds sends the current move of the client to the game and the php compares with the move inte the database and return 1 or 0 depending on weather the move is differmt, eg the new position of peices must be loaded. After the data has been got by ajax, the js run a script which basically sees if 1 or 0 was returned and if 0 was returned it runs another ajax query to fetch the new positions. These positions are given in terms of x and y and represent the absolute position of the peices. The javascript then simply moves the relevant peices to that square. Its all good up to which point, (if it wasn't this would be in the ajax section but as the ajax works perfectly I am puttin it under javascript). The problem is that when the peices are moved. the wz_dragdrop.js file does not seem to recognise the movent, meaning that the peie in question is not draggable. However if you click ont the square the peice moved from it is dragable, and the peice jumps to that square. --------- What I would like it someone who knows the wz_dragdrop library who knows if there is a way to move an element using javascript that dragdrop will recognise. atm my script does this. document.getElementById(n+'.dIi15v').style.left = document.getElementById('xpos'+n).value+'px'; document.getElementById(n+'.dIi15v').style.top = document.getElementById('ypos'+n).value+'px'; which physically moves the peices but dragdrop doesn't notic the movement. any help would be great as I am not that good with javascript and this one is reaslly beyond me. I though it would be as smle as finding a variable in the wz script which carries the x and y pos for each element but it doesn't appear so. Many thanks MadnessRed
×
×
  • 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.