Go Back   Wiki NewForum > Career Forum > Tech Forum & Tutorial > HTML Forum & Tutorial

HTML Forum & Tutorial End-To-End Process HTML / XHTML / CSS

Creating and handling a form with multiple submit ****ons with images


Reply
Views: 1359  
Thread Tools Rate Thread Display Modes
  #1  
Old 08-09-2010, 11:31 AM
bholas bholas is offline
Award Winner
 
Join Date:
Apr 2010
Posts: 5,181
Default Creating and handling a form with multiple submit ****ons with images

Wondering how to create an HTML form with more than a single submit ****on with images and check which of those ****ons was clicked?
First, let's take a look at the HTML code required to make a form with multiple "submit" image ****ons. Note how each of the "image" type input ****ons have unique names. We will be using these names to find out which of the ****ons was pressed. The SRC attribute should point to unique image files, although technically you could use the same image file for all three of those input ****ons. We're assuming that the script we're calling to handle the form submission (or the ACTION attribute) is "mulibtn.asp" which we will demonstrate next.



First name:







Listing #1 : HTML code. Download mulibtn.htm (0.3 KB).


Following is a sample Active Server Pages (ASP) script that you can use in conjunction with the above form. When an image ****on is clicked, the script will receive the position of the mouse pointer as X, Y coordinates relative to the clicked image. For example, the coordinates of the ****on "bsubmit1" will be sent to the script as "bsubmit1.x" and "bsubmit1.y" If a ****on other than "bsubmit1" was clicked, the coordinates for "bsubmit1" will contain an empty value (Nil, Empty, NULL or "" value depending on the scripting language you're using). In our ASP sample which is using VBScript, we'll check for the "nil" value.


<%
btnID = "?"

if Request.Form("bsubmit1.x") <> nil then
btnID = "1"
elseif Request.Form("bsubmit2.x") <> nil then
btnID = "2"
elseif Request.Form("bsubmit3.x") <> nil then
btnID = "3"
end if
%>
Submit ****on ID: <%=btnID%>



Listing #2 : ASP/VBScript code. Download mulibtn0.asp (0.29 KB).


Finally we'll combine the HTML code and the ASP script code into a single file as follows:


<%
btnID = "?"

if Request.Form("bsubmit1.x") <> nil then
btnID = "1"
elseif Request.Form("bsubmit2.x") <> nil then
btnID = "2"
elseif Request.Form("bsubmit3.x") <> nil then
btnID = "3"
end if
%>
Submit ****on ID: <%=btnID%>



First name:







Listing #3 : ASP/VBScript code. Download mulibtn.asp (0.39 KB).

Reply With Quote
Reply

Tags
website tips

New topics in HTML Forum & Tutorial

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump


Powered by vBulletin® Version 3.8.10
Copyright ©2000 - 2019, vBulletin Solutions, Inc.