Solved

Using an image as submit button

Posted on 2001-07-11
15
196 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
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/…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

707 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

21 Experts available now in Live!

Get 1:1 Help Now