This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes HTML, CSS and JavaScript and the fly likes Display the picture in [object HTMLImageElement] using PHP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Display the picture in [object HTMLImageElement] using PHP" Watch "Display the picture in [object HTMLImageElement] using PHP" New topic
Author

Display the picture in [object HTMLImageElement] using PHP

Koldo Urrutia
Ranch Hand

Joined: Dec 16, 2011
Posts: 85
Hey


I tried to access a cookie that has a [object HTMLImageElement] but when I try to echo it, it simply prints that out: [object HTMLImageElement] I want it to display the picture.


I used a canvas2image JS library, in Javascript, I was able to generate the image and display it but I want to save the html code in a cookie and just display it.


The library is this one BTW: http://www.nihilogic.dk/labs/canvas2image/


I need to get the string that is useable in a normal


<img src="">


How can I do this?


Thanks
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
cookies hold a string, when you do toSting on an object, you get the result that you are seeing.

Eric
Koldo Urrutia
Ranch Hand

Joined: Dec 16, 2011
Posts: 85
Eric Pascarello wrote:cookies hold a string, when you do toSting on an object, you get the result that you are seeing.

Eric

Well, instead of display the string, how can I display a object?

Another alternative way Ive thought of doing is using a hidden input field like so:


Problem is that I cant access it on another page!

Explaining my action: This already does link me (this code is actually inside a button with a onclick action that leads me somewhere else so like I mentioned it is not needed (the action)) to somewhere but in action I cant put a link because it is dynamically generated. Action AFAIK is mandatory so I just put that to try it to pass. For some reason in PHP (with a simply <?php echo $_POST[imagen]; ?> I cannot get it to show. It just shows up blank.
As you can see, in value the data is perfectly there but I cannot pass it to another page.

I hope this can help you guys out give me some advice. Thanks!
Koldo Urrutia
Ranch Hand

Joined: Dec 16, 2011
Posts: 85
After I breaked it down, Ive basically worked it down to this:


My JS:



My new submit button:



and last the destination:



imgstr has the correct value as I do a alert after the JS line and it shows it correctly.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Are you posting to the form? Can't tell where you are adding the new element.

I thought it would be more like



Koldo Urrutia
Ranch Hand

Joined: Dec 16, 2011
Posts: 85
Eric Pascarello wrote:Are you posting to the form? Can't tell where you are adding the new element.

I thought it would be more like




I would put that intead of what? Could you give me some more information? From what I see that is a jQuery instruction.


Thanks!
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Koldo Urrutia wrote:
Eric Pascarello wrote:I would put that intead of what? Could you give me some more information? From what I see that is a jQuery instruction.
Thanks!


You could not figure out it was basically the same thing as



but the difference is I am targeting the form instead of the document?

But I just noticed you are targeting a parent, are you using iframes?

Eric
Koldo Urrutia
Ranch Hand

Joined: Dec 16, 2011
Posts: 85
Yes. i am using a iframe
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Display the picture in [object HTMLImageElement] using PHP