Jump to content

show image from input?


Voldemort

Recommended Posts

I'm trying to make a section on my site where a user enters their name into a form, presses submit, and an image (theirname.gif) is shown, without reloading the screen.

 

This is what I have right now, but it's not working...

 

<html>
<head>
<title>New Page 1</title>
</head>

<body>

<script language=javascript>
function showimage (elem) {
var url = elem.username.value;
var imagearea = document.myimage;

imagearea.innerHTML = "<img src='images/" + url + ".gif' />";
}
</script>

<form name="form" method="POST" action="javascript:showimage(document.form)">
<p align="center">Enter your name:<br>
<input type="text" name="username" size="20"><br>
<input type="button" value="Submit" name="enter" onclick="javascript:showimage(document.form)"></p>
</form>
<div name="myimage"> </div>
</body>

</html>

 

images/(name).gif is a php image by the way

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.