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
https://forums.phpfreaks.com/topic/54518-show-image-from-input/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.