Solved

How do I make a 'gif image' a submit button?

Posted on 1998-08-04
14
261 Views
Last Modified: 2010-04-09
Everyone knows you can just use the ugly old Submit button with the codes 'input type = submit....' but what if you want to make a nicer looking button, say with a gif that you made.  My question is how do you make the gif a submit button  NOTE: I know I can use links but I can't do that because there are several hidden form fields (pasted below) that need to be passed with the button.  You may may have to use javascript to solve this problem but I'm not sure - does anybody know.  I would appreciate your help.  Thanx.  


                                                              THE CODES

<form action="/scripts/samples/search/queryhit.idq" method="GET">
<input type="hidden" name="CiMaxRecordsPerPage" value="10">
<input type="hidden" name="CiScope" value="/">
<input type="hidden" name="TemplateName" value="queryhit">
<input type="hidden" name="CiSort" value="rank[d]">
<input type="hidden" name="HTMLQueryForm" value="/samples/search/queryhit.htm">
 <table BORDER="0" width="15">
<tr>
<td >
<input type="text" size="6" maxlength="100" name="CiRestriction"value="Search">
</td>
</tr>
<tr>
<td>
<img src="searchgo.gif" border="0" width="72" height="22">
 </td>
</tr>
<tr>
<td>
<img src="/searchtext.gif">
</td>
</tr>
</form>

0
Comment
Question by:mendelsohn
  • 4
  • 3
  • 2
  • +4
14 Comments
 
LVL 28

Expert Comment

by:sybe
Comment Utility
<input type="image" scr="image.gif">
0
 
LVL 28

Expert Comment

by:sybe
Comment Utility
Sorry, typo:

<input type="image" src="image.gif">

You can treat it like an image tag, so include width=".." height=".." border="0" etc.


0
 
LVL 8

Expert Comment

by:jbirk
Comment Utility
sybe's suggestion is normally the way to do this.  It will submit the form when you click on the image.

However there is also another way to do it with <IMG SRC="image.gif"> instead of <INPUT type="image" src="image.gif">
It would look like this:
<A HREF="JavaScript:document.theForm.submit();"><IMG SRC="image.gif"></A>
And then you have to name the form: "theForm" (or substitute whatever name you prefer and change it also in the JavaScript command).

Doing it this way, you can also use the onclick command and onmouseover without some of the problems that <input type=image> tags sometimes have.  Of course, using the <imput type=image> is ususaly the way to do it since it's simpler and works fine as long as nothing complicated needs to be done with the form.

Also, two caveats about using my proposed method:
1. The form must have a CGI action (will not work with mailto actions)
2. it won't work in IE if you put the submit section as an onclick event instead of called from the anchor href (it's fine as it is now)

Hope this helps,
Josh
0
 
LVL 10

Expert Comment

by:MasseyM
Comment Utility
<form action="/scripts/samples/search/queryhit.idq" method="GET">
<input type="hidden" name="CiMaxRecordsPerPage" value="10">
<input type="hidden" name="CiScope" value="/">
<input type="hidden" name="TemplateName" value="queryhit">
<input type="hidden" name="CiSort" value="rank[d]">
<input type="hidden" name="HTMLQueryForm" value="/samples/search/queryhit.htm">
 <table BORDER="0" width="15">
<tr>
<td >
<input type="text" size="6" maxlength="100" name="CiRestriction"value="Search">
</td>
</tr>
<tr>
<td>
<input type="image" src="searchgo.gif" border="0" width="72" height="22">
 </td>
</tr>
</form>

0
 
LVL 28

Expert Comment

by:sybe
Comment Utility
Mendelsohn,

You have rejected my proposed answer. Which is up to you of course. But you did not give any comment why. The thing is that it is an answer to your question. It might be not the answer you are looking for, but then it would be nice to have some explanation. Then, me (and other experts) can try to answer your question differently.

0
 

Expert Comment

by:eriklee
Comment Utility
SYBE's answer looks perfect to me.. or is it just me..?
0
 

Expert Comment

by:cdiweb
Comment Utility
Sybe's <input type="image" src="image.gif"> will certainly work.

Don't reject answers unless they are WRONG. Both answers posted here are correct, and technically speaking, identical. (Although MassyMs has more meat to it, the answer is still the same.)


0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 10

Expert Comment

by:MasseyM
Comment Utility
Why did you reject my answer?
0
 

Author Comment

by:mendelsohn
Comment Utility
Sybe's responded first with the right answer and ahould get the points.
0
 

Author Comment

by:mendelsohn
Comment Utility
Sybe - repost an answer and I will give you the points - sorry about the problems and thanx for your help.
0
 
LVL 8

Expert Comment

by:jbirk
Comment Utility
Good move mendelsohn!
-Josh
0
 
LVL 10

Expert Comment

by:MasseyM
Comment Utility
Correct, but whos answer are you going to use?  I bet your code looks a lot like mine...

- Matt

ps. give Sybe the points though
0
 
LVL 28

Accepted Solution

by:
sybe earned 280 total points
Comment Utility
Thanks mendelsohn
0
 

Expert Comment

by:kessyclown
Comment Utility
couldn't you do it the other way around? Instead of making from a gif a button, make the gif a background for the grey button?
That's a lot easier I think
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

763 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

12 Experts available now in Live!

Get 1:1 Help Now