Select image with ExecCommand('insertimage') and write path to textbox

  •  05-19-2008, 4:14 PM

    Select image with ExecCommand('insertimage') and write path to textbox

    Does anyone know how to use the editor1.ExecCommand('insertimage'); to upload and select an image and have the Insert button cause a textbox to be filled with a path to the image file?
     
    Here is the javascript I have tried but doesn't write path back to imageFld textbox:
         function callInsertIMG() 
        { 
       var editor2 = document.getElementById('<%=editor2.ClientID%>');
                editor2.FocusDocument(); 
                var editdoc = editor2.GetDocument(); 
                editor2.ExecCommand('new');
                editor2.ExecCommand('insertimage');
                InputIMG();
                document.getElementById("ctl00_ContentPlaceHolder1_imageFld").focus();
        }   
       
        function InputIMG()
        {
      var editor2 = document.getElementById('<%=editor2.ClientID%>');
            var editdoc = editor2.GetDocument(); 
            var links = editdoc.getElementsByTagName("a");      
            if(links.length>0&&links[links.length-1].href!="") 
      { document.getElementById("ctl00_ContentPlaceHolder1_imageFld").value = links[links.length-1].href;      
      } 
      else
      {
       setTimeout(InputIMG,500);
      }          
        }
    Thanks for any help
View Complete Thread