HTML - Html Form Sumbit\image Button
Hi,
I am struggling to find a solution to my problem, believe me i have searched google with every different combination of words to find the answer to this question but i cant find one. Basically have i done this: <form action="page.cgi" method="GET"> <input type="image" src="play.gif" name="cmd" value="START" > </form> Ok, the button with the image displays, BUT! Instead of passing the value START to "cmd" within "page.cgi" it passes the x and y coordinates of the image where i have clicked. Now this works perfectly like this: <form action="page.cgi" method="GET"> <input type="submit" name="cmd" value="START" > </form> So my question is, how do use a submit button with an image, without getting the coordinates returned. Any help would be GREAT. Similar TutorialsHi, I got a HTML form whose submit button doesnt seem to be working, Any help would be appriciated. The link to the form is http://new.johnnyshotel.com/contact.html . I tried the same form in a different plain html file and it seems to work but when I insert it back into this webpage template the submit button doesnt seem to work. Thanks in advance. I am having a bit of a problem. I need to replace a submit button with an image (addtocart.gif). It sounds easy enough, but for some reason when I change the coding, my link does not pop-up in a new window, as it currently does. I need the image to open up my shopping cart preview page. Any help would be greatly appreciated. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script type="text/javascript"> var mywindow; var features='width=530,height=500,left=200,top=200,scrollbars=yes'; window.onload=function() { document.forms[0].target='mypopup'; document.forms[0][3].onclick=function() { makePopup(); } } function makePopup() { if(mywindow) { mywindow.close(); } mywindow=window.open('','mypopup',features); mywindow.focus(); } </script> </head> <body> <form method="post" action="http://ww11.aitsafe.com/cf/add.cfm"> <div> <input type="hidden" name="userid" value="D745330"/> <input type="hidden" name="price" value="19.95"/> <select name="product"> <option value="Red shirt w/ logo (XS)">X-Small</option> <option value="Green shirt w/ logo (S)">Small</option> <option value="Blue shirt w/ logo (M)">Medium</option> <option value="Red shirt w/ logo (L)">Large</option> <option value="Green shirt w/ logo (XL)">X-Large</option> <option value="Blue shirt w/ logo (XXL)">XX-Large</option> </select> <p> <input type="submit" name="post" class="submit" value="submit"/> </div> </form> </body> </html> I have created a button which is linked to some JavaScript to dim the screen when it is pressed. using CSS I have changed the image of the button using a graphic. The graphic is a .PNG as it uses transparency but when set the image as the button it has lost all transparency is there anyway to enable the transparency of the .PNG this is the code I am using to do it. Code: <input type="button" onClick="d()" class="button"> Ok, so I hope there is a simple answer to this. I just haven't been able to figure it out. I have a basic form that has a dropdown menu. I am using an image as the submit button. The problem I am having is that the image does not align vertically properly next to the dropdown menu. Below is what my form looks like in the browser. Any ideas how to get this aligned correctly? Thanks for all help! Is there a way to put a custom graphic for the browse button in the file upload field, similar to how you can use a custom graphic for the submit button? I have an HTML form that allows users to browse for an image. I need that image to then be displayed on that form once the "Upload" button is pressed. Code anyone? I am creating a website that has a search button with an image. I would like to know if there is some simple code that I can include that would display the same basic image with a different color when the user mouses over the button. Here is the code: <FORM name="searchform" onSubmit="return validateSearch();" METHOD="POST" ACTION="search_results_lt.asp"> <INPUT TYPE="text" NAME="Search" VALUE="" SIZE="20" > <INPUT TYPE=IMAGE SRC="images/search_button.gif" Name="SearchButton" Value="Submit"> </FORM> **** Thanks for your help, Robin So in January 2006 I posted a question about "making two buttons in one" 3 years and 5 months later i am happy to announce that I have found a solution. Ok, so no I have not spent the last three years looking, but the need for one came around again yesterday so I revisited the project. All I needed was "simple" image toggle. Image 'A' click it once it changes to image 'B' click it again it changes back to image 'A' All the "image toggle" codes I could find were extremely complex. I thought I had finally found one, it wasn't perfect, but it was the smallest and most basic thing I could find. HTML Code: <html> <head> <style type="text/css"> .on {background-image:url(playlist_btn.png); background-repeat:no-repeat;} .off {background-image:url(playlist_btn_x.png); background-repeat:no-repeat;} </style> <script language="javascript"> function togglestyle(el){if(el.className == "on") {el.className="off";} else {el.className="on";}} </script> </head> <body> <div id="onoff" class="playlist_btn"><img src="blank.gif" width="50 height="50" onclick="togglestyle(onoff)"></div> </body> </html> I tested it, it worked, so I considered problem solved. I placed it in my page and nothing. Turns out it wont work with a doc type - so it's useless. Other problems, I'm not big on using "blank gif's" unless I have to, if you want multiple image toggles you need a new JS function for each one, and two lines of css as well. And, though I rarely use image rollovers anymore, it would certainly not be possible in this method. So it was back to the drawing board. Well, I had actually already found the solution a few minuets prior to finding out that the above code is so good. I had coded a button that on rollover shows a tooltip, when you click the button, the text in the tool tip, changes, chick again and it reverts. All done with a simple showHide javascript function, that i am finfing out has many uses. here is the awesome code: Code: function showHide(elementid){ if (document.getElementById(elementid).style.display == 'none'){ document.getElementById(elementid).style.display = ''; } else { document.getElementById(elementid).style.display = 'none'; } } function hideShow(elementid){ if (document.getElementById(elementid).style.display == ''){ document.getElementById(elementid).style.display = 'none'; } else { document.getElementById(elementid).style.display = ''; } } I wont take credit for the showHide code, but I will take credit for the hideShow portion, obviously a monkey could have coded the revers, but iot does make it that much more universal. As the original code was designed to show something that was hidden, add the revers to hide something that is showing and it's perfect. Now I will take a moment to say, though I have yet to find a problem with the code, it seems to work in most browsers, firefox, ie, safari, and validates for WC3 - In sure it has it's flaws. Until now, to show and hide divs I had used the MM_showHideLayers JavaScript function, which by default used the visibility style. It is of course a good script, and has many uses, it's not very big, but it is somewhat complex. The other thing to think about is that invisible objects still take up space. That's what is cool about the display:none: style, is that is not only invisible but it doesn't take up space. So here is how I used the above to JavaScript to make a simple onclick image toggle: HTML Code: <img id="on" src="on.png" width="50" height="50" onClick="javascript:hideShow('on'); javascript:showHide('off')" alt="on"> <img id="off" src="off.png" width="50" height="50" onClick="javascript:hideShow('off'); javascript:showHide('plus')" style="display:none;" alt="off"> Cool huh? Now this example does not have a rollover either, but since it uses to individual images and is not replacing one image wioth another you could easily apply a rollover to both images. But, hold on, look at the above code, isn't that essentially a rollover? Change the first onClick to onMouseOver and the second to onMouseOut and look at that a 'brand new' method for mouseovers. So lets take a look at this for a second, and compare MM_swapImage to this new hideShow method. As far as CSS rollovers I definitely prefer them to the MM_swapImage method, as they use a minimal amount of code. However they actually take a lot of math, construction the buttons is somewhat tedious, because css buttons use 1 image and change it's position, to work well you have to use a "blank.gif" and the the css can really add up if you have a lot of buttons: Also, you can't go directly to a button in the document, you have to fish through the css to make any adjustments. But they are fast, they don't need to be preloaded and... they are pretty cool. But anyway, swapImage and hideShow... The left is the MM_swapImage method. Now when you use the swapImage js you also have to use MM_swapImgRestore, MM_findObj, MM_preloadImages. You don't have to use the preload script but it does make thing work faster... supposedly, but that requires a onload script in the body tag, and if you have a lot of rollovers your body tag can get really long really quick. So what are the advantages, well we know for sure it works, and you only need on image in the document, however actualy having the image you are "swapping" too actually in the document can add functionality. So as you can see, on the right, the showHide method is, in total code, much smaller. True you do need to use two images, so the total code in the body is longer but, it's more than evened out bu the minimal JavaScript, and I think it's worth it. You don't need to use a preloader, you have full control over both images, the up and over state, and unlike the swapImage method, though it's rare you would need to, your up and over images can actually be different sizes, which is kind of cool. So here's the basic code for a rollover: HTML Code: <img id="up" src="up.png" width="50" height="50" onMouseOver="javascript:hideShow('up'); javascript:showHide('over')" alt="up"> <a href="http://google.com"><img id="over" src="over.png" width="50" height="50" onMouseOut="javascript:hideShow('over'); javascript:showHide('up')" style="display:none;" alt="over" border="0"></a> To add a link the button you just apply it to the "over state" image. And unlike swapImage, though it is overkill, you can also add a "downstate" image quite easily. So, back to the on/off button here is how you would code it using showHide with rollovers. HTML Code: <img id="on" src="on.png" width="50" height="50" onMouseOver="javascript:hideShow('on'); javascript:showHide('onover')" alt="on"> <img id="onover" src="on_over.png" width="50" height="50" onMouseOut="javascript:hideShow('onover'); javascript:showHide('on')" onClick="javascript:hideShow('onover'); javascript:showHide('offover')" style="display:none;" alt="onover"> <img id="off" src="off.png" width="50" height="50" onMouseOver="javascript:hideShow('off'); javascript:showHide('offover')" style="display:none;" alt="off"> <img id="offover" src="off_over.png" width="50" height="50" style="display:none;" onMouseout="javascript:hideShow('offover'); javascript:showHide('off')" onClick="javascript:hideShow('onover'); javascript:showHide('off')"alt="offover"> So here is what is going on: you have the upstate on.png image, when you mouse over it on.png is hidden and on_over.png is displayed. When you click on_over.png it is hidden and off_over.png is display, mouse off it and off.png is displayed. Make scene? Now be aware, when you click, you are also in a scene "mousing off" so some flickering can occur. Firefox handles everything pretty well, IE and Safari not so much. When you click the on_over.png the click tells it to hide on_over.png and show the off_over.png, at the same time the mouseoff tells it to hide on_over.png and show the on.png. So fortunately the toggle with rollovers isn't perfect, but perhaps some more tweaking of the code or maybe, in this case swapImage would work better to do the rollovers... But all in all I'd say its a solid concept. If you feel compiled to do so, reply with any comments, concerns or flaws you see. let's say we want to create a button named HOME which will lead to the index.html after clicking.and the image has to be images/img1.jpg .code for this ? i used that <button type="button" value="home" onClick=window.location="index.jpg" "img" scr="images/img1.jpg></button> link worked but image didn't appear. also,onClick thing has to do something with the java scripts too? Hi I am trying to create a button for my webpage so that when the mouse hovers over the button the image changes, then when the mouse leaves button the image changes back to the original. I have this but its not working <head> <body><button><img src=http://fc07.deviantart.net/fs6/i/2005/093/5/e/Beep_by_fatking.png width="150" height="150" title="Beep" <img src="http://fatking.deviantart.com/art/Shwf-27296191?q=gallery%3Afatking%20randomize%3A1&qo=2" onmouseover="this.src="http://fc09.deviantart.net/fs9/i/2006/005/8/2/Shwf_by_fatking.jpg" onmouseout="this.src="http://fc07.deviantart.net/fs6/i/2005/093/5/e/Beep_by_fatking.png"> Hi everyone, I would really appreciate your help here. I'm not entirely sure if this is html or javascript but... I would like to create a button which is disabled until a certain link is clicked on the webpage... If this possible at all? Thank you Paul I've tried multiple ideas but basically I just want it to be a regular grey button with the dimensions of the image I want to slap on the front of it so it will to a click down animation when someone clicks on it but so far all I get is this... HTML Code: <FORM METHOD="LINK" ACTION="mms://media.huntingtonnews.net/video/2007/BillDargusch-Downtowns-1.wmv"> <BUTTON TYPE="submit"><IMG SRC="http://www.huntingtonnews.net/images/baseball1-tn.jpg" alt="wow"></BUTTON> </FORM> And that is pretty good but the grey parts of the button sticking out make it look horrible. Does anyone know a way to shrink the button to the image size?... Codeguru Hi, I'm new to HTML and Javascript so please excuse this basic question: will a <button> always postback or do i need to add onclick="return false;" to stop it postback. The reason I ask, I want to use JQuery and the examples just have a <button> and an event in the javascript to run some code on the click event. however without the onclick="return false;" attribute on my button the page just posts back. am i missing something fundemental here? matta Hello, I would like to set up a simple webpage with some instructions on the top, 2 buttons in the middle and a "counter" at the bottom. I am very out of practice with html so I would really appreciate someone telling me the code I need to program the following: I want it so that each time the user clicks a button a number appears for 1 second and then dissapears. I want to be able to define what that number is (and it will depend on how many times the user has clicked). For example, on the first click, I want the value "1" to appear for one second and then dissapear (if the user clicked, say, the left button; the right button will have different numbers). On the second click, I want the value "0" to appear for one second and then dissapear, etc. It is also important that I somehow restrict the user from clicking very fast because I want them to see each value, so there needs to be some way to disable the buttons while the value is being shown and then reenabled when the value dissapears. I also need a "counter" at the bottom of the screen that tallies up the total of the values that are being shown on the button. For example, after that first click the counter would have "1" and after the second click the counter would still say 1. Finally, when the user has clicked 100 times, I want the button to become disabled and another "end" button to appear and be enabled. Thanks for any help! Adrian OK so basically I have made a quick HTML code to hide some You Tube videos because they spoil the thing I was doing. My testing html worked perfectly, all with this total code: Quote: <html> <body> <h1>__________________________________________________________________________________________</h1> <div style="margin:20px; margin-top:5px"><div class="quotetitle"><strong>Spoiler :</strong> Video: <input type="button" value="Show" style="width:60px;font-size:10px;margin:0px;padding:0px;" onclick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.innerText = ''; this.value = 'Masquer'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = 'Afficher'; }" /></div><div class="quotecontent"><div style="display: none;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="330" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"> <param name="allowFullScreen" value="true" /> <param name="allowscriptaccess" value="always" /> <param name="src" value="http://www.youtube.com/v/w-W6YJvrKPk?fs=1&hl=en_US&rel=0" /><embed type="application/x-shockwave-flash" width="550" height="330" src="http://www.youtube.com/v/w-W6YJvrKPk?fs=1&hl=en_US&rel=0" allowscriptaccess="always" allowfullscreen="true"></embed> </object></div></div></div> <div style="margin:20px; margin-top:5px"><div class="quotetitle"><strong>Spoiler :</strong> Video: <input type="button" value="Show" style="width:60px;font-size:10px;margin:0px;padding:0px;" onclick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = ''; this.innerText = ''; this.value = 'Masquer'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = 'Afficher'; }" /></div><div class="quotecontent"><div style="display: none;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="550" height="330" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"> <param name="allowFullScreen" value="true" /> <param name="allowscriptaccess" value="always" /> <param name="src" value="http://www.youtube.com/v/qXh47Qa92kk?fs=1&hl=en_US&rel=0" /><embed type="application/x-shockwave-flash" width="550" height="330" src="http://www.youtube.com/v/qXh47Qa92kk?fs=1&hl=en_US&rel=0" allowscriptaccess="always" allowfullscreen="true"></embed> </object></div></div></div> <h1>__________________________________________________________________________________________</h1> </body> </html> But anyways, what I did was copy and paste the red text into my website, but the buttons don't show up. Is there any way I can make it work? I am using a host from THESE GUYS. Any help? {And yes I know I used quote instead of code tags, had to because it cut it off} Hello Friends, I have page which is a type of form with many textbox and labels. I have used table for designing this form. How can I use a submit button so that it is placed in the center of the cell at the bottom of the page. In short I need my Submit Button in the center of the page. Please let me know as early as possible. I need to add a browse button to my webpage which has the same functionality as that of the Browse button in windows application. Is there any particular Java API for same, or can it be done using javascript "Home" appears on the button.When we click it it goes to "index.html" the image related to home button is home.jpg. So button's image is home.jpg ,after clicking the button it should take to a link we have given and button's name is Home.how to do that? thanks Hello, I would like to move my button or <FORM> to different position than at the default location. How can I do that? |