473,662 Members | 2,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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*******@compu terholistics.co m
Jul 23 '05 #1
5 3545
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>Fo rmImage Test</title>
<script>
var selimage = NewImage();
selimage.src = "nosel.jpg"
function dothisnow(){
var picid = document.getEle mentById("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=dothisn ow
();>
<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*****@speakn et.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>Fo rmImage 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(docu ment.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_Ea rth</li>
<li>clem_full_m oon</li>
<li>erosreconst ruct_near</li>
<li>giotto_hall ey</li>
<li>lspn_comet_ halley1</li>
<li>hst_pluto_c haron</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('Apol lo17_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 + "erosreconstruc t_near_T.jpg";

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

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

var selimage = new Image();
selimage.src = nasaPath + "hst_pluto_char on_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*******@compu terholistics.co m
Jul 23 '05 #5
"SPEAKIT" <SP*****@speakn et.net> wrote in message news:<QS******* ************@bi gnews3.bellsout h.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
2528
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 sliders (RGB) on a website and a button to process it. Is this at all possible and could someone point me in the right direction or
3
6688
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 application is based on mysql and php on a remote server, and is accessed by the user via a web browser, primarilly IE. The image file names are built up by the server side php scripts, and so a URL for the image file is created, but the file itself is...
3
2141
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, can I send the data of the image to the applet ?
35
2656
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
2552
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 problem is that i am not able to get the latest image on the page, it keeps showing the old page. But when i hit the refresh button on the toolbar it correctly gets the latest image and displays it in the control. But that has another problem, it...
7
7915
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 image are perfect before submission. This involves converting any uploaded image to a Base64 String and holding that in a hidden form field until either the post gets submitted to the database or the image gets replaced with another one. I...
5
7908
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 type="image" id="addnews" src="/Image/add24.png"
16
2860
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 ass and the app will be used internally so I'm not too worried about users who aren't using javascript. I'm using the following javascript to detect whether or not they've hit enter: if(document.layers) {
1
4076
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 hotspots on the image. One being correct(a) and the other incorrect(b). When the user clicks on the correct hotspot or place on the image, it should score and retain that value until the end of the quiz. At the end of the quiz, there is a submit button...
0
8432
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8856
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8762
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1992
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.