dimitar Posted November 19, 2007 Share Posted November 19, 2007 Hi. I made some script. Its some kind of simple blog. At the form where i put content i gave just title and body textareas. But i want to add some options like inserting images(when klick a litle icon for image pop-up to show and inside the pop-up to insert the url. and that to appear to body form.Or maybe like this:its not important what code will be inserted, its important that i want to see the system. I think this is not possible with php, but i asked any case. JS is also accepted;D Link to comment Share on other sites More sharing options...
justsomeguy Posted November 19, 2007 Share Posted November 19, 2007 You'll need to use Javascript for the interface, not PHP. You can have the image button run a Javascript function that will use the prompt function to get a value from the user like the location of the image, and then you can insert the image tag with their value for the src attribute into the text field. Link to comment Share on other sites More sharing options...
dimitar Posted November 19, 2007 Author Share Posted November 19, 2007 Can you write me the code. FOr example i have: <form method="post"><textarea></textarea somwere in tthe form i will add pa picture link.Please write the code Link to comment Share on other sites More sharing options...
Ingolme Posted November 19, 2007 Share Posted November 19, 2007 I'm not sure if <textarea>s can actually contain anything other than text, but you can try this.HTML: Image: <input type="text" id="image" /> <input type="button" value="Click here" onclick="addImage()" /><br /><textarea id="output"></textarea> This goes in the <head> of the document: function addImage() {im = document.createElement("img");im.src = document.getElementById("image").value;document.getElementById("output").appendChild(im);} Link to comment Share on other sites More sharing options...
Synook Posted November 20, 2007 Share Posted November 20, 2007 Textareas can't contain images without some pretty complex JavaScript (I.E. has window.exec() but that is browser-specific), but you could insert image code into the textarea <script type="text/javascript">function insertimage(target) {src = prompt("Enter Image Location");document.getElementById('target').value += "<img src=\"" + src + "\" />";}</script> Then the button uses the onclick handler to call the script, and target refers to the id of the textarea. Link to comment Share on other sites More sharing options...
dimitar Posted November 20, 2007 Author Share Posted November 20, 2007 Yes, i was looking for code, not for image shower:D:D.Anyway thanks to both. Link to comment Share on other sites More sharing options...
dimitar Posted November 21, 2007 Author Share Posted November 21, 2007 What should i change/add to this to work? <html><head><script type="text/javascript">function insertimage(target) {src = prompt("Enter Image Location");document.getElementById('target').value += "<img src=\"" + src + "\" />";}</script></head><body><form><textarea cols="10" rows="10" id="target"></textarea><input type="submit" name=""></form></body></html> Link to comment Share on other sites More sharing options...
justsomeguy Posted November 21, 2007 Share Posted November 21, 2007 Add a link or something to actually run the Javascript function. Link to comment Share on other sites More sharing options...
dimitar Posted November 21, 2007 Author Share Posted November 21, 2007 I dont have any idea of how to do that, becouse i never learned javascript. Link to comment Share on other sites More sharing options...
Synook Posted November 22, 2007 Share Posted November 22, 2007 Something like <a href="javascript:insertimage('target')">Insert Image</a> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.