Solved

Using an image as submit button

Posted on 2001-07-11
15
210 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
[X]
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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
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/…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

691 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