Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Drawing and converting

    Hi, I was wondering - how can I convert something that a user draws inside canvas? Say, they draw a square, how could I convert that to print "You have drawn a square" - this would be posted to a text file.

    Thanks in advance.

  • #2
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Bump.

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Flint, Michigan, USA
    Posts
    632
    Thanks
    1
    Thanked 21 Times in 21 Posts
    How did the user draw the square? Did s/he use your draw-a-square function or put in four separate line segments for you to recognize as a square?

  • #4
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thank you for your response.

    It basically draws a square altogether (not 4 seperate lines).

    Any advice would be greatly appreciaited.

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    Flint, Michigan, USA
    Posts
    632
    Thanks
    1
    Thanked 21 Times in 21 Posts
    Quote Originally Posted by mv0010 View Post
    It basically draws a square altogether.
    Whatever "it" is in that sentence (some kind of draw-a-square function?) can state, "You drew a square."

    I expect that I'm not properly understanding the question.

  • #6
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Yes exactly, I meant draw-a-square type function (using Canvas and JavaScript functions), would then give the user the option to state "You drew a square" - this would be posted to a .txt file.

    Sorry if I haven't been too clear in asking my question.
    Last edited by mv0010; 01-20-2012 at 01:52 PM.

  • #7
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    So basically you want to know how to store a text in a .txt file server side and how you initiate the store process from the client in Javascript?

    client side Javascript
    Code:
    var mystring = "......";   // string to be posted to the server
    var http = new XMLHttpRequest();
    http.open('POST', 'StoreAsTxt.php', true);
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http.send('txt=' + encodeURIComponent(mystring));
    The PHP side may be solved by someone else ... I am not much into PHP. The text will be available in PHP as $_POST["txt"]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •