Sunday, 15 January 2012

transfer html var to php -


I'm new to PHP, if I write a piece of the html5 canvas code, and store the var attempts value in Want to transfer mysql to canvas PHP session, how to do it? Compatible codes are in Star, Thaks in advance

  & lt; Div id = "aside" & gt; & Lt; Canvas id = "microwave" width = "600" height = "500" style = "border: 1 px solid # c3c3c3;" & Gt; & Lt; / Canvas & gt; & Lt; Script & gt; Var bodystyle = document.body.style; BodyStyle.mozUserSelect = 'none'; BodyStyle.webkitUserSelect = 'none'; Var img = new image (); Var canvas = document.query selector ('canvas'); Canvas.style.backgroundColor = 'Transparent'; Canvas.style.position = 'Done'; Var imgs = ['p_2.jpg', 'p_3.jpg', 'p_4.jpg', 'p_5.jpg', 'p_6.jpg', 'p_7.jpg', 'p_8.jpg', 'p_9.jpg , 'P_11.jpg', ' 'P_18.jpg', 'p_19.jpg', 'p_20.jpg', 'p_21.jpg', 'p_22.jpg', 'p_23.jpg', 'p_24.jpg', 'p_25.jpg', 'p_26 .jpg ']; Var num = Math.floor (Math.random () * 24); Img.src = imgs [number]; Img.addEventListener ('Load', function (e) {var ctx; // var w = img.width, // h = img.height; var w = 600; h = 500; var offsetX = canvas.offsetLeft, offsetY = Canvas.offsetTop; var MouseDown = false; function layer (CTX) {ctx.fillStyle = 'gray'; ctx.fillRect (0, 0, w, h);} event eventDown (e) {e.preventDefault (); Muizidon = true;} function eventUp (e) {e.preventDefault (); mouseden = false;} function eventove (e) {e.preventDefault (); if (mooledown) {if (e.changedTouches) {e = e change Gone touch [e.changedTouches.length-1];} var x = (e.clientX + document.body.scrollLeft || e.pageX) - offset x || 0, y = (e.clientY + document.body. ScrollTop | | E.pageY) - Offset U. with 0 (ktx) {startPath () // R Reset (X, Y, 20, 20); Fill ();}}} Function Console (e) {e.preventDefau Liter (Var) = 0; var datas = canvas.getImageData (0,0, W, H); (Var i = 0; i & lt; datas.data.length; i ++) for (if (datas.data [i] == 0) {num ++;};}; ** Tryup = num / (w * h); **} canvas.wind = w; Canvas.height = h; Canvas.style.backgroundImage = 'url (' + img.src + ')'; Ctx = canvas.getContext ('2D'); Ctx.fillStyle = 'Transparent'; Ctx.fillRect (0, 0, w, h); // 绘制 矩形 layer (ctx); Ctx.globalCompositeOperation = 'Destination-Out'; Canvas.addEventListener ('TouchStart', EventDown); Canvas.addEventListener ('touchend', eventUp); Canvas.addEventListener ('touchmove', eventMove); Canvas.addEventListener ('Masudown', EventDown); Canvas.addEventListener ('mouseup', EventUp); Canvas.addEventListener ('mousemove', eventMove); Canvas.addEventListener ("click", mint); }); & Lt; / Script & gt; & Lt; / Html & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt; & Lt ;? Php ** $ _ session ["attempt"] = $ effort; **? & Gt;  

This is not the best solution, however, you can use an AJAX request Call php script and pass Java from javascript to php script.


No comments:

Post a Comment