PDA

View Full Version : Help with image on form...


Adrianaa03
10-05-2004, 01:40 AM
I'm having some trouble with a form on my website. What I've done is passed an image from one page to another using this script:

<script language="JavaScript" type="text/javascript">
<!--

if (location.search) {
var image_filename = location.search.substring(1)
document.write('<IMG SRC="' + image_filename + '" width="110"
height="80">')
}
//-->
</script>

This is working great and the image shows up in the form just where I want it. Problem is, I don't know how to get this image (not the actual image but at least the image filename) to get sent to me through email when the user hits the submit button. Everything else on the form gets sent to me except this image (the image will always be different depending on what image was clicked on the page before) I also want to send this image to a confirmation page. Can someone please help me out with this?
Thanks...Adriana

RysChwith
10-05-2004, 12:18 PM
The easiest thing to do would be to add an id to the image, then use that to reference it. In the code where the IMG tag is written, you'd modify it like so:


document.write('<IMG id = "imgSelected" SRC="' + image_filename + '" width="110"


Then you would be able to reference that image in code as follows:


document.getElementById( "imgSelected" )


Note that "imgSelected" can actually be any string you want, just as long as it's the same in both places.

Rys

Adrianaa03
10-05-2004, 01:08 PM
Thanks for the reply Rys. Once I do this, can I use:

document.getElementById( "imgSelected" )

in the confirmation page to pull up the image or do I have to write another script?

RysChwith
10-06-2004, 07:06 AM
Not as such. All that's going to do is allow you to reference the image on that particular page. This does, however, give you a means to pass it along to the next page. In order to tell you how to do that, though, I'd need to see some code. Note that you may end up dealing with server-side stuff to pull this off.

Rys