Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Get value from form submit using image

Posted on 2002-04-10
5
263 Views
Last Modified: 2006-11-17
Hi,

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? :-)

Thanks,
David.
0
Comment
Question by:DSE
5 Comments
 
LVL 7

Expert Comment

by:CJCraft
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:
http://myserver/myweb/whichimage.asp?image2.x=74&image2.y=35

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
next

%>
0
 

Author Comment

by:DSE
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,

David.
0
 
LVL 10

Accepted Solution

by:
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
onclick="document.ImageName.Value='submitImageOne.gif'"

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.

onclick="jumpme(submitImageOne.gif)"

<script language="Javascript">
function jumpme(img){
  document.ImageName.Value=img
  form.myform.submit()
}
</script>
0
 
LVL 58

Expert Comment

by:Gary
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.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
GaryC123
EE Cleanup Volunteer
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Time/Date Query 11 43
Html form and modal / img src -problem 3 29
Html Table looping 4 25
Executing a script on a timer online 5 20
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

840 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