Solved

Using an image as submit button

Posted on 2001-07-11
15
199 Views
Last Modified: 2012-08-13
Hello,
I am displaying several (this will vary) thumbnails to user as a result of a query.  I am using the images as submit buttons. I want user to be able to click on thumbnail image and be taken to the appropriate page.

My problem is that I can't seem to pass the image value to the next page.  Can this be done?  This is what my code looks like so far.

Thanks

Mike



<%@ Language=VBScript %>

<%
Dim openConnection
Dim rsBaskets
dim strBasketName
dim strThumbnail
dim strTemp
dim strName
strTemp = "yes"

set openConnection = Server.CreateObject("ADODB.CONNECTION")
set rsSWbaskets = server.CreateObject("ADODB.Recordset")
openConnection.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Inetpub\wwwroot\newsite\dataOne.mdb"
set rsSWbaskets = openConnection.Execute("Select * FROM basket WHERE birthday LIKE '" & strTemp & "' ")
rsSWbaskets.MoveFirst

%>

<HTML><HEAD><TITLE>Sample</TITLE></HEAD>
<BODY>
<FORM NAME ="BetaMax" Method=Post Action="testo.asp">
     
<% While not rsSWbaskets.EOF %>

  <%
    strThumbnail = rsSWbaskets("thumbnail")
    strName = rsSWbaskets("name")
  %>
  <CENTER>
     <INPUT TYPE ="IMAGE" NAME="imgSearch" VALUE="<%=strThumbnail%>" src=<%=strThumbnail%>  width="100" height="100">
     <br>
  <h3><%Response.Write strName %>
      <br>
      </H3></CENTER>
     
<% rsSWbaskets.movenext
   Wend
%>
     
<%
  rsSWbaskets.close
  openConnection.Close
  set rsSWBaskets = nothing
  set openConnection = nothing
%>
</CENTER></form></BODY>
</HTML>
0
Comment
Question by:MichaelVB
  • 4
  • 3
  • 3
  • +3
15 Comments
 
LVL 7

Expert Comment

by:daniel_c
ID: 6275344
<INPUT TYPE ="IMAGE" NAME="imgSearch" VALUE="<%=strThumbnail%>" src=<%=strThumbnail%>  width="100"
height="100" OnClick="document.BetaMax.submit();">
0
 

Author Comment

by:MichaelVB
ID: 6275367
This does get me to the next page.  However, the VALUE, strThumbnail, does not get passed.  Here is the page I am using to test this.

Thanks alot.

Mike

<%@ Language=VBScript %>

<%

     dim strVariable
     strVariable = Request.Form("imgSearch")

%>
<HTML>

<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>


<% Response.Write(strVariable) %>

<P>&nbsp;</P>

</BODY>
</HTML>
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 6275374
I don't think you can put a value on an input type=image tag daniel, this is a typical <image> submit tagline;

<input type=image src=<%=strTHumbNail%>>

If you put the <value> in a hidden field it will work.

But why not just use something like this?

<a href="testTo.asp?varVal=<%=strThumbnail%>"><immg src="<%=strThumbnail%>"></a>
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6275496
<input type="image"> will only return you the x and y coordinates clicked. Use a hidden field like what mgfranz suggested. Then get the value of the hidden field in your page specified in your form action. That will work

hongjun
0
 
LVL 1

Expert Comment

by:anupkarade
ID: 6275822
Hi buddy..
      According to the secenario presented by you
      I think the better idea is to use the thumbnails as
      links and pass the value as querystring to the
      target page... This is usually done in all shopping
      cart type of application...Use the image tag

      here is the code
   
     
   <a href="testPage.asp" target=_blank><img src=<%=strThumbnail%> value="<%=strThumbnail%>"></a>



this works fine...
                                 regards
                                         Anup
0
 
LVL 4

Expert Comment

by:ravi_raj123
ID: 6275873
HI,
If you have to submit any other values other then the image name, then the above said method i.e. hyperlink method won't work, you have to pass all the values through query string,so try this way... this way you can submit the whole form values without doing much work.

<script language="javascript">
function gopage(pagename) {

    document.frm.action="page.asp?pagename=" + pagename;
    document.frm.submit();
}
</script>
<form name="frm" method="post">
<input type="image" src=<%=strThumbnail%> value=<%=strThumbnail%> onclick="gopage(this.value)">
</form>


Good Luck...:)
0
 
LVL 4

Expert Comment

by:ravi_raj123
ID: 6275885
Oops!!! I made a mistake in the above answer. SORRY

Here is the correct one.

<script language="javascript">
function gopage(pagename) {

   document.frm.pn.value=pagename
   document.frm.submit();
}
</script>
<form name="frm" method="post" action="gopage.asp">
<input type="image" src=<%=strThumbnail%> value=<%=strThumbnail%> onclick="gopage(this.value)">
<input type="hidden" name="pn">
</form>

Sorry once again for the previous answer.
0
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.

 
LVL 7

Expert Comment

by:daniel_c
ID: 6277634
mqfranz, I just copy and paste from MichaelVB's code.
The concept that I actually wanted to give is that you can use OnClick event, but anyway mqfranz's suggestion makes sense! :)
0
 

Author Comment

by:MichaelVB
ID: 6279674
mgfranz,

First let me thank you for your help. I'm trying to use your suggestion but I'm still having a problem.

This is what my code looks like
<A HREF="testo.asp" varVal=<%=strThumbnail%>"><img src="<%=strThumbnail%>"></a>

My question is that I am not sure how to retrieve the value of varVal in testo.asp

This is what I am trying to do:
strVariable = Request.Form("varVal")

This doesn't work... Doesn't the Request object need the name of an <INPUT> tag?  If so, what would I use in this case?  

Thanks again.

Mike
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6280248
Does you address bar displays the querystring after the link is clicked?

hongjun
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6280250
Sorry miss that.

TRY THIS
strVariable = Request.QueryString("varVal")

MUST WORK!

hongjun
0
 
LVL 33

Expert Comment

by:hongjun
ID: 6280259
And this if your name of the asp is testTo.asp
<A HREF="testTo.asp?varVal=<%=strThumbnail%>"><img src="<%=strThumbnail%>"></a>


Or if it is testo.asp
<A HREF="testo.asp?varVal=<%=strThumbnail%>"><img src="<%=strThumbnail%>"></a>


You seems to have conflicting name of the asp file.

hongjun
0
 
LVL 18

Accepted Solution

by:
mgfranz earned 75 total points
ID: 6280706
Thanks for speaking for me hongjun, want to pay my bills too?

Mike,

"This is what my code looks like
<A HREF="testo.asp" varVal=<%=strThumbnail%>"><img src="<%=strThumbnail%>"></a>"

This is what is should look like;

<a href="testto.asp?varVal=<%=strThumbnail%>"<img src="<%=strThumbnail%>" border=0></a>

"My question is that I am not sure how to retrieve the value of varVal in testo.asp

This is what I am trying to do:
strVariable = Request.Form("varVal")"

You can retrieve it with a simple Request(), ASP uses QueryString by default;

strVariable = Request("varVal")

Mark



0
 

Author Comment

by:MichaelVB
ID: 6282115
Worked like a charm. Thanks again for your help.
Mike
0
 
LVL 18

Expert Comment

by:mgfranz
ID: 6285855
Welcome.
0

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

Title # Comments Views Activity
Smart quotes being changed on insert 9 50
Group by correlation 4 55
Adding Datediff to staistics page 2 49
Time/Date Query 11 38
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…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

895 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

15 Experts available now in Live!

Get 1:1 Help Now