View Full Version : SRC value in forms

01-24-2009, 05:45 PM
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

Philip M
01-24-2009, 06:28 PM
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.