Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. Add/change image in javascript

Add/change image in javascript

Scheduled Pinned Locked Moved Web Development
javascripttutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PeriyasamyRamachandran
    wrote on last edited by
    #1

    Dear developers, I have to implement the image upload functionality in javascript. I got more examples, but i expect to upload the image or photo "without showing the input field". Example, i have the button "Add/Change image". I don't want to show the input field to bind the file. can you guys give any idea or suggestion?.. Thanks, Periyasamy.

    A 1 Reply Last reply
    0
    • P PeriyasamyRamachandran

      Dear developers, I have to implement the image upload functionality in javascript. I got more examples, but i expect to upload the image or photo "without showing the input field". Example, i have the button "Add/Change image". I don't want to show the input field to bind the file. can you guys give any idea or suggestion?.. Thanks, Periyasamy.

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      What do you mean ? You can show image in img tag. To upload, you need to browse using file control and upload the files to the server. .Just show the image by calling img.src = url and you are done. When you change the url of img.src it will automatically call the server and update the image in the browser. Upload file needs postback. :) [Note : I left out flash or any browser based plugins]

      Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


      My Latest Articles-->** Simplify Code Using NDepend
      Basics of Bing Search API using .NET
      Microsoft Bing MAP using Javascript

      E 1 Reply Last reply
      0
      • A Abhishek Sur

        What do you mean ? You can show image in img tag. To upload, you need to browse using file control and upload the files to the server. .Just show the image by calling img.src = url and you are done. When you change the url of img.src it will automatically call the server and update the image in the browser. Upload file needs postback. :) [Note : I left out flash or any browser based plugins]

        Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


        My Latest Articles-->** Simplify Code Using NDepend
        Basics of Bing Search API using .NET
        Microsoft Bing MAP using Javascript

        E Offline
        E Offline
        Eduard Keilholz
        wrote on last edited by
        #3

        May be handy to tell that when you have your html image tag ![My picture](/images/image.jpg) you'll be able to use the image object in Javascipt using the getElementById() function :

        var myImage = document.getElemtnById('myPicture');
        // And then set the source of the image (which will change the image)
        if (myImage)
        myImage.src = "/images/image2.jpg";

        .: I love it when a plan comes together :. http://www.zonderpunt.nl

        A 1 Reply Last reply
        0
        • E Eduard Keilholz

          May be handy to tell that when you have your html image tag ![My picture](/images/image.jpg) you'll be able to use the image object in Javascipt using the getElementById() function :

          var myImage = document.getElemtnById('myPicture');
          // And then set the source of the image (which will change the image)
          if (myImage)
          myImage.src = "/images/image2.jpg";

          .: I love it when a plan comes together :. http://www.zonderpunt.nl

          A Offline
          A Offline
          Abhishek Sur
          wrote on last edited by
          #4

          Perfect... :thumbsup:

          Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


          My Latest Articles-->** Simplify Code Using NDepend
          Basics of Bing Search API using .NET
          Microsoft Bing MAP using Javascript

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups