Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 18th, 2007, 12:55 PM
Friend of Wrox
Points: 489, Level: 7
Points: 489, Level: 7 Points: 489, Level: 7 Points: 489, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2006
Location: Berkshire, United Kingdom.
Posts: 104
Thanks: 9
Thanked 1 Time in 1 Post
Default Issue with image buttons


Hope you guys can help!

I have an issue with using image buttons which i have not found any related forum items on..

Essentially when using image button my process page does not recognise the action eg

Code:
<form method="post" action="test.asp" target="_top">
<input type="submit" name="action" value="Save" class="bs">
<input type="submit" name="action" value="Delete" class="bs">
</form>
<-- test.asp -->

Code:
<% if Request.form("action")="Save" then
response.write("Do something")
End if
Works

How ever if i use

Code:
<form method="post" action="test.asp" target="_top">
<input type="button" name="action" value="save" src="../images/save.gif" alt="Save">
<input type="button" name="action" value="delete" src="../images/delete.gif" alt="Delete">
</form>
Computer says No! In the test.asp page.

My knowledge of form elements is not great so if anyone has any thoughts it would be appreciated.

Cheers

Aspless

 
Old December 18th, 2007, 01:26 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Your logic is doing exactly what you are asking it to do:

<% if Request.form("action")="Save" then
response.write("Do something")
End if %>

But your save button is:
<input type="button" name="action" value="save" src="../images/save.gif" alt="Save">

Save != save


================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========
 
Old December 18th, 2007, 01:49 PM
Friend of Wrox
Points: 489, Level: 7
Points: 489, Level: 7 Points: 489, Level: 7 Points: 489, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2006
Location: Berkshire, United Kingdom.
Posts: 104
Thanks: 9
Thanked 1 Time in 1 Post
Default


The Link was actually ..
Code:
<input type="image" name="action" value="save" src="../images/save.gif" alt="Save">
typo at my end

So by changing Submit to Image is the issue just unsure if i can use an image attribute over submit.

Cheers


Aspless

 
Old December 18th, 2007, 01:54 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You missed that completely.

The value of your image button is 'save' your If is testing for the value of 'Save'.

You logic is working as it should because it is preforming a case senstive evaluation and save <> Save.

Adjust the value in your image button or adjust your code:
<% if ToLower(Request.form("action"))="save" then
response.write("Do something")
End if %>

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========
 
Old December 18th, 2007, 02:12 PM
Friend of Wrox
Points: 489, Level: 7
Points: 489, Level: 7 Points: 489, Level: 7 Points: 489, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2006
Location: Berkshire, United Kingdom.
Posts: 104
Thanks: 9
Thanked 1 Time in 1 Post
Default


Thanks ..

Yes that completly went passed.

My fault for not checking my own example code.

Both values are now the same and thanks for the case code.

The issue is still present how ever and by changing the type ref from image to submit the process works .. just not image..

Cheers


Aspless

 
Old December 18th, 2007, 02:49 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

what result does Response.Write(Request.Form("action")) yeild?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========
 
Old December 18th, 2007, 06:24 PM
Friend of Wrox
Points: 489, Level: 7
Points: 489, Level: 7 Points: 489, Level: 7 Points: 489, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2006
Location: Berkshire, United Kingdom.
Posts: 104
Thanks: 9
Thanked 1 Time in 1 Post
Default

Very good point.

Yes i tried the response.write which did not return a value so i am guessing when you change -

Code:
<input type="submit" name="action" value="save">
to


Code:
<input type="image" name="action" value="save" src="../images/save.gif" alt="Save">
That the data is not transferred.

So unless you use type="submit" the process does not work.

I can alter the submit button with CSS but preferably would use an image.

Cheers


Aspless




 
Old December 18th, 2007, 06:46 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

They way you are doing it correct. One of many ways around this would be:

<input type="image" name="action" value="save" src="../images/save.gif" alt="Save" onClick="Javascript:(formName.submit());">

NOTE - change formName to your form name.

Wind is your friend
Matt
 
Old December 18th, 2007, 07:24 PM
Friend of Wrox
Points: 489, Level: 7
Points: 489, Level: 7 Points: 489, Level: 7 Points: 489, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2006
Location: Berkshire, United Kingdom.
Posts: 104
Thanks: 9
Thanked 1 Time in 1 Post
Default

Mat,

Thanks for the input ..

I have changed the form name "form1" and used the following code in the process page but still no result yet.

Initial page
Code:
<form name="form1" method="post" action="test.asp">
<input type="image" name="action" value="save" src="../images/save.gif" alt="save" onClick="Javascript:(form1.submit());">
</form>
Process page

Code:
Response.Write(Request.Form("action"))
result = Request.Form("action")
Response.Write(result)
Any thoughts?

Cheers

Aspless

 
Old December 18th, 2007, 08:22 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Im not sure you can retrieve values this way. Will this meet your need (cut n paste code):

<%
if request.form("someVal") <> "" then
   Response.Write "The button you clicked holds the following value: " & request.form("someVal")
else
   response.write "form not submitted yet"
end if
%>
<html>
<head>
    <title>Untitled</title>
    <script>
    function sendInfo(aValue)
    {
       form1.someVal.value = aValue;
       form1.submit();
    }
    </script>
</head>
<body>
<form name="form1" method="post" action="test.asp">
 <input type="hidden" name="someVal" value="">
 <input type="image" name="action" value="Save" src="../images/save.gif" alt="Save" onClick="sendInfo('Save');">
 <bR>
 <input type="image" name="action" value="Delete" src="../images/delete.gif" alt="Delete" onClick="sendInfo('Delete');">
</form>
</body>
</html>

Wind is your friend
Matt




Similar Threads
Thread Thread Starter Forum Replies Last Post
image/db issue chaosengel PHP How-To 1 July 11th, 2007 02:22 PM
radio buttons to display 'mandatory' image on form onionGirl Javascript How-To 0 May 10th, 2007 05:57 AM
multiple Image submit buttons set default to last sam HTML Code Clinic 2 June 30th, 2004 02:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.