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

    SRC value in forms

    I have a program with an form and an input that is an image. i want to be able to change the image after a function is activated but i dont know how to do this with javascript

    function change(){
    document.a.b.src = "something.jpg"

    <form name="a">
    <input name="b" type="image" src="x.x">
    <input name="c" type="button" value="click" onclick="change()">

    basically when that button is clicked i want that function to set the src to an actual image. Thanks in advance for any help

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    London, England
    Thanked 2,573 Times in 2,551 Posts
    Here you are:-

    <div id = "div1"><img src="One.gif" id = "theImage"></div>
    <input name="c" type="button" value="Click to change image" onclick="change()">
    <script type = "text/javascript">
    function change(){

    BTW, the time to say "thanks" is afterwards, not beforehand which gives the impression that you take other people's unpaid assistance for granted. Or as British politician Neil Kinnock put it, "Don't belch before you have had the meal." Prefer to use "please" beforehand and if you find a response helpful then you can use the "Thank User For This Post" button.


    Posting Permissions

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