473,386 Members | 2,042 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Get image based on user input

I'm sorry to ask what must be a very simple question, but I just can't seem
to get this to work.
Right now I am using the javascript 'prompt' to enter a photoid and the
script that I am using uses document.write
to put the proper image on the page ....i.e. PHOTOID =".jpg"

What I want is a simple user input text area and when submit is clicked a
placeholder image beneath is exchanged for the proper
image based on the user's input.
example: User enters re4555 and the image re4555.jpg replaces the image
nosel.jpg
that I have created which basically says 'no image selected'.

please,please help, this is very frustrating.
Thank you
we*******@computerholistics.com
Jul 23 '05 #1
5 3515
Lee
SPEAKIT said:

I'm sorry to ask what must be a very simple question, but I just can't seem
to get this to work.
Right now I am using the javascript 'prompt' to enter a photoid and the
script that I am using uses document.write
to put the proper image on the page ....i.e. PHOTOID =".jpg"

What I want is a simple user input text area and when submit is clicked a
placeholder image beneath is exchanged for the proper
image based on the user's input.
example: User enters re4555 and the image re4555.jpg replaces the image
nosel.jpg
that I have created which basically says 'no image selected'.


Is there a reason why you want to use document.write()?
Am I correct that you are not actually submitting a form?
It would probably be easier and more helpful to correct your
code than to show you new code.

Jul 23 '05 #2
here is an example of something that doesn't work.....lol

<html>
<head><title>FormImage Test</title>
<script>
var selimage = NewImage();
selimage.src = "nosel.jpg"
function dothisnow(){
var picid = document.getElementById("picid").value;
selimage.src = picid +".jpg";
}
</script>
</head>
<body>
<form>
<p align="center">
Please Enter your Photo ID:<br>
<input type=text id="picid" name="picid">
<input type=button value="Click Here to See Your Photo" name="clicker"
id="clicker" onClick=dothisnow
();>
<p align="center"><img src="nosel.jpg" name="selimage" id="selimage">
</form>
</body>
</html>
--sorry for being an idiot.....
Jul 23 '05 #3
In article <cG******************@bignews4.bellsouth.net>,
"SPEAKIT" <SP*****@speaknet.net> wrote:
here is an example of something that doesn't work.....lol


I kind of lost track of the changes that I made.
Robert
Try this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title>FormImage Test</title>
<script type="text/javascript">

var nasaPath = "http://spaceplace.nasa.gov" +
"/en/educators/images/solarsystem/";

function dothisnow(name){
/* Get the reference to the image. */
var picId = document.images["imageId"];
/* Set the name of the image.
This causes the new image to be loaded. */
picId.src = nasaPath + name + "_T.jpg";
}
</script>

</head>
<body>
<form name="myForm">
<p style="text-align: center;">
Please Enter your Photo ID:<br>
<input type=text
name="picid"
size="25">
<br><br>
<input type=button
value="Click Here to See Your Photo"
name="clicker"
onClick=
"dothisnow(document.forms['myForm'].elements['picid'].value);">
<br>
<img id="imageId"
onerror="alert('Could not find the image.');">
</form>

<p>Some values to type or to cut and paste:
<ul>
<li>Apollo17_Earth</li>
<li>clem_full_moon</li>
<li>erosreconstruct_near</li>
<li>giotto_halley</li>
<li>lspn_comet_halley1</li>
<li>hst_pluto_charon</li>
</ul>
<p>These image are from NASA. See:<br>
http://spaceplace.jpl.nasa.gov/en/ed...s_images.shtml
</p>
<script type="text/javascript">
// Fill in the default image. I am too lazy to type in the
// full path name.

dothisnow('Apollo17_Earth');

// Best to put the images at the end.
var selimage = new Image();
selimage.src = nasaPath + "Apollo17_Earth_T.jpg";

var selimage = new Image();
selimage.src = nasaPath + "clem_full_moon_T.jpg";

var selimage = new Image();
selimage.src = nasaPath + "erosreconstruct_near_T.jpg";

var selimage = new Image();
selimage.src = nasaPath + "giotto_halley_T.jpg";

var selimage = new Image();
selimage.src = nasaPath + "lspn_comet_halley1_T.jpg";

var selimage = new Image();
selimage.src = nasaPath + "hst_pluto_charon_T.jpg";

</script>
</body>
</html>
Jul 23 '05 #4
You are the best!!!!!!!
It works exactly as I needed!!!!!
I customized a little and voila all up and running!!!

Thank YOU thankyou THANK you THANKYOU!!!

oh.....and I learned a lot too.......
about syntax and the proper way to call an elementbyid and such.....

thank you so much

sd
we*******@computerholistics.com
Jul 23 '05 #5
"SPEAKIT" <SP*****@speaknet.net> wrote in message news:<QS*******************@bignews3.bellsouth.net >...

thank you so much


Glad to get the positive feedback.

Robert
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Michel | last post by:
Hi folks, I wonder if what I have in mind is possible, maybe even not all that complicated: I have an image, which is a yellow circle. I want this yellow circle to change color by having 3...
3
by: coolsti | last post by:
I need some help here. I am making an application which allows a user to look at a series of picture files one at a time, and enter the outcome of various visual tests to a database. The...
3
by: Jordan Gomila | last post by:
Hi, I wish to get the pixels os an image to transform it. There is any posibility to do this with javascript ? I have done with java, but I can't load web images from other http servers,...
35
by: Stan Sainte-Rose | last post by:
Hi, What is the better way to save image into a database ? Just save the path into a field or save the image itself ? I have 20 000 images (~ 10/12 Ko per image ) to save. Stan
5
by: ramendra | last post by:
how to refresh a image control to pick up the latest image file on a asp.net page. i am generating a image based on the input from the user and displaying it on the page through image control. The...
7
by: Neo Geshel | last post by:
Greetings. I have managed to stitch together an awesome method of posting text along with an image to a database, in a way that allows an unlimited number of previews to ensure that text and...
5
by: Mark Woodward | last post by:
Hi all, I'm trying to set up a 'control panel' consisting of a table of icons. The early stages: http://www.deepinit.com/controlcentre.php Each of these is set up like: <td> <input...
16
by: browntown | last post by:
so I have this application I'm nearly finished with. The only thing the client has requested is the ability to submit the form by pressing "enter". I didn't think this would be a huge pain in the...
1
by: sourcie | last post by:
I am changing an existing quiz found on "JavaScriptKit.com Multiple Choice Quiz" I have an image. Instead of using the radio buttons with the normal true/false question, I want to place two...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.