473,396 Members | 2,018 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

using image on submit button

52
hi,
i want to use an image on my submit button, but im having problems with it, as it does not execute the javascript associated with it.
For example, this is my exit button:

<input type="image" name="exit" src="images/exit.jpg" border="0" onClick="window.close();">

When, i click on in, a window pops-up asking confirmation to exit or not, even if i say no, it goes back to the previously opened page. im having the same problem with other submit buttons when i use <input type=image>

Is there any other way i can put an image using <input type=submit> itself?
Please help.
Apr 26 '07 #1
15 13153
KevinADC
4,059 Expert 2GB
You could try using an image as the background for a submit button. It may not look the same as an actual <intput type=image> but it would probably be close. The problem you described is typical of javascript to close a window or do other things, it leaves control to the user and not the javascript otherwise webpages could take control of your web surfing like the bad old days when pop-up after pop-up would take you all over the internet and you could barley prevent it from happening.
Apr 26 '07 #2
mallz
52
You could try using an image as the background for a submit button. It may not look the same as an actual <intput type=image> but it would probably be close. The problem you described is typical of javascript to close a window or do other things, it leaves control to the user and not the javascript otherwise webpages could take control of your web surfing like the bad old days when pop-up after pop-up would take you all over the internet and you could barley prevent it from happening.

hi,
i did a lot of searching regarding this, and i found that <button type=submit>
can be used.

<button type=submit ><img src="images/go.gif" border="0" alt="Continue to the next page" /> </button>
but,i am getting a grey boxed border around the image, how can i make it disappear.
also, from where do i call my javascript code?
Apr 26 '07 #3
drhowarddrfine
7,435 Expert 4TB
In your css:

button{
margin:0;
padding:0;
border:0;
}

Not a javscript guy but:
<button type=submit onclick="alert('hello')"><img src="image.png" border="0" alt="Continue to the next page" />
Apr 26 '07 #4
mallz
52
In your css:

button{
margin:0;
padding:0;
border:0;
}

Not a javscript guy but:
<button type=submit onclick="alert('hello')"><img src="image.png" border="0" alt="Continue to the next page" />
hi, it is calling its associated javascript code, but im still getting a boxed rectangular grey border around my image.
Apr 26 '07 #5
drhowarddrfine
7,435 Expert 4TB
With that CSS in place? Need a link or the code.
Apr 26 '07 #6
mallz
52
With that CSS in place? Need a link or the code.
yes, with the css...............and the code u posted......
i tried putting an id, and identifying it but it still does not work...
Apr 26 '07 #7
mallz
52
yes, with the css...............and the code u posted......
i tried putting an id, and identifying it but it still does not work...
here is what i used:
<button type="button" onClick="window.close();"><img src="images/exit.jpg" border="0" alt="Exit!!" /> </button>
ive called my css file in the head section with the code uve posted..
Apr 26 '07 #8
drhowarddrfine
7,435 Expert 4TB
There must be other markup affecting this. Here's my test page:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2.    "http://www.w3.org/TR/html4/strict.dtd">
  3. <html>
  4. <head>
  5. <title></title>
  6. <style type="text/css">
  7. button{margin:0;padding:0;border:0}
  8. </style>
  9.  
  10. </head>
  11.  
  12. <body>
  13. <button type="button" onclick="alert('test');"><img src="1.gif" alt="Exit!!" /> </button>
  14. </body>
  15. </html>
Apr 26 '07 #9
KevinADC
4,059 Expert 2GB
hi, it is calling its associated javascript code, but im still getting a boxed rectangular grey border around my image.
what browser and browser version are you using?
Apr 26 '07 #10
mallz
52
what browser and browser version are you using?
hi, i tried the sample program u had posted, but im having the same problem.
im using Internet Explorer, version 6.0
Apr 27 '07 #11
KevinADC
4,059 Expert 2GB
this should work, no CSS required:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2.    "http://www.w3.org/TR/html4/strict.dtd">
  3. <html>
  4. <head>
  5. <title></title>
  6.  
  7. </head>
  8.  
  9. <body>
  10. <form><input type="image"
  11. onclick="alert('Wassup?')";
  12. src="frog.gif">
  13. </form>
  14. </body>
replace frog.gif with your image.
Apr 27 '07 #12
mallz
52
this should work, no CSS required:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2.    "http://www.w3.org/TR/html4/strict.dtd">
  3. <html>
  4. <head>
  5. <title></title>
  6.  
  7. </head>
  8.  
  9. <body>
  10. <form><input type="image"
  11. onclick="alert('Wassup?')";
  12. src="frog.gif">
  13. </form>
  14. </body>
replace frog.gif with your image.
ive tried this, but, its associated javascript on an <input type="image"> does not function properly.
Apr 27 '07 #13
drhowarddrfine
7,435 Expert 4TB
Then this is a javascript problem and you need to go to that board for this.
Apr 27 '07 #14
KevinADC
4,059 Expert 2GB
ive tried this, but, its associated javascript on an <input type="image"> does not function properly.

Works fine for me in IE6, IE7 and FF2. Do you have javascript disabled maybe?
Apr 27 '07 #15
hi, it is calling its associated javascript code, but im still getting a boxed rectangular grey border around my image.
just put background-color in your css to match the color of the body and thats it:

button{
background-color:#FFFFFF;
margin:0;
padding:0;
border:0;
}
Nov 19 '07 #16

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Colin Steadman | last post by:
I have two buttons on my form and need to know which was clicked. If I setup the buttons like this: <input type="submit" value="submit" name="submit_to_array"> <input type="submit"...
4
by: Csaba2000 | last post by:
I want to be able to programatically click on the center of an <INPUT type=image ...> element (I only care about IE 5.5+). This should work regardless of whether IE has focus. Normally you would...
2
by: e | last post by:
IE6. I have a form that can take a while to process once the user submits it. So upon submittal of the form, the onclick event for the submit button changes some text on the screen to say 'please...
2
by: Matt | last post by:
In the following code, I have 2 questions regarding submit button with image. 1) Does this code <input type="image" name="populate" src="populate.gif"> behave the same as an HTML submit button...
3
by: Adam | last post by:
Hey guys, I've decided to stop banging my head against the wall and just ask you guys for the answer. I can't seem to find it. I have a form in which I have multiple submit buttons; only, I'm...
7
by: KiwiBrian | last post by:
On a web page I have a graphic for a Shopping Cart Submit button. It is within a form and working fine. I would like to perform an image swap to an identical graphic of a different colour when I...
0
by: David | last post by:
Hello all. I am trying to implement my first server control and have run into two problems that I cannot solve. I need the assistance of someone with more experience. My goal was to create an...
16
by: browntown | last post by:
so I have this application I'm nearly finished with. The only thing the client has requested is the ability to submit the form by pressing "enter". I didn't think this would be a huge pain in the...
4
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all I have the following code: I am trying to use the value of the image button to evaluate what plan the user has chosen, i.e. it request("submit1")="Basic", then the user chose basic plan...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.