Get value from form submit using image

Posted on 2002-04-10
Last Modified: 2006-11-17

I am using images as a method of submitting a form. This is because images look so much better than a grey button :-) Each image is designed to submit the form and process it depending upon the button clicked.

However, after submitting the form the asp page that receives it is unable to retrieve the value of the submit image. I know that using an ordinary button the value is passed along with the form and is retrievable using Request.Form("buttonname"). This doesn't seem possible with images despite spending days trying!

The only way around this problem that I can find is to use the image.x properties to determine which image has indeed been clicked by its click coordinates.

Is there a simpler way using the value parameter or is complication the only way? :-)

Question by:DSE

Expert Comment

ID: 6931110
When you use images in a FORM they return thier NAME attribute along with a coordinate value pair (x,y) showing where on the image the user clicked (hey, wasn't *my* idea!).

For example, here's the GET line from an HTML document with two images in the FORM:

Since you may not know which items will be returned (image1 or image2) you need to change your ASP code a bit to 'walk' through the returned items from the FORM:


for each varItem in Request.QueryString
   Response.Write varItem & "=" ' display NAME attribute
   Response.Write Request(varItem) & "<P>" ' display VALUE attribute


Author Comment

ID: 6932407
Thanks CJCraft...I should have elaborated some more...I am passing the form values and image names using POST. This is because we can't allow anyone to access the pages using parameters in the URL.

The problem seems to be that the name values are "lost" during the submission using POST.

Thnaks for any suggestions,

LVL 10

Accepted Solution

slamhound earned 50 total points
ID: 6933218
Create a hidden field called something like ImageName. When you click on an image, use some JavaScript to write the image name to the new hidden field before the form is submitted.

This could be like

Or, if you're already using the onclick to submit form send it to a JavaScript funciton that will first place the relevant value in the hiddn field and then submit the form.


<script language="Javascript">
function jumpme(img){
LVL 58

Expert Comment

ID: 8831055
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept Answer by slamhound
Please leave any comments here within the next seven days.
EE Cleanup Volunteer

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now