{"id":345,"date":"2006-05-09T11:25:06","date_gmt":"2006-05-09T10:25:06","guid":{"rendered":"http:\/\/www.matazone.co.uk\/blog\/?p=345"},"modified":"2006-05-10T00:24:44","modified_gmt":"2006-05-09T23:24:44","slug":"a-bit-of-code-simple-form-rollover-submit","status":"publish","type":"post","link":"https:\/\/www.matazone.co.uk\/blog\/?p=345","title":{"rendered":"A bit of code&#8230; Simple form rollover submit"},"content":{"rendered":"<p>I&#8217;m in the final stages of putting a new site online, and I decided to put a little polish on some of the buttons. Given that the whole thing is done in PHP and involves lots of forms, I needed a way to make a rollover image that could submit the form for me.<\/p>\n<p>A search on Google initially made this look like it was going to be rather complex&#8230; Well, not complex, but unnecessarily lengthy:<\/p>\n<p><a href=\"http:\/\/www.idocs.com\/tags\/forms\/index_famsupp_107.html\">http:\/\/www.idocs.com\/tags\/forms\/index_famsupp_107.html<\/a><\/p>\n<p>Look at the state of that! Lines of code running all over the over the place!<\/p>\n<p>But then I found <a href=\"http:\/\/www.htmlcodetutorial.com\/help\/archive.php\/o_t__t_685__submit-form-image-rollover.html\">this thread<\/a>, with the following lovely bit of code:<\/p>\n<p>[input type=&#8221;image&#8221; value=&#8221;someValue&#8221; src=&#8221;yourImage.gif&#8221; width=&#8221;widthInPixels&#8221; height=&#8221;heightInPixels&#8221; onmouseover=&#8221;javascript:this.src=&#8217;yourImageRollover.gif&#8217;;&#8221; onmouseout=&#8221;javascript:this.src=&#8217;yourImage.gif&#8217;;&#8221;\/]<\/p>\n<p>[replace the square brackets with angle brackets]<\/p>\n<p>I customised it a bit so that it would submit my form and to give it some more user-friendly tags:<\/p>\n<p>[input name=&#8221;Submit&#8221; type=&#8221;image&#8221; id=&#8221;Submit&#8221; onmouseover=&#8221;javascript:this.src=&#8217;siteimages\/button-tell-me-down.gif&#8217;;&#8221; onmouseout=&#8221;javascript:this.src=&#8217;siteimages\/button-tell-me-up.gif&#8217;;&#8221;  value=&#8221;Submit&#8221; src=&#8221;siteimages\/button-tell-me-up.gif&#8221; alt=&#8221;Tell me this clue!&#8221; \/]<\/p>\n<p>[replace the square brackets with angle brackets]<\/p>\n<p>But otherwise the code is all there. It doesn&#8217;t have a pre-load function in it, but for a form-submission button you&#8217;d hope that the image file sizes are going to be so tiny that they won&#8217;t take a moment to download. I reuse this code a lot on my pages too, so one preload and the whole site looks swanky without the need for piles and piles of Javascript at the top of every page.<\/p>\n<p>I&#8217;m a big fan of good coding. When something as simple as and useful as a rollover can be achieved with a line of code then you know that things are working the way they should.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m in the final stages of putting a new site online, and I decided to put a little polish on some of the buttons. Given that the whole thing is done in PHP and involves lots of forms, I needed a way to make a rollover image that could submit the form for me. A &hellip; <a href=\"https:\/\/www.matazone.co.uk\/blog\/?p=345\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">A bit of code&#8230; Simple form rollover submit<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1071,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[12],"tags":[],"class_list":["post-345","post","type-post","status-publish","format-standard","hentry","category-computing"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5bQqr-5z","_links":{"self":[{"href":"https:\/\/www.matazone.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.matazone.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.matazone.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.matazone.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/1071"}],"replies":[{"embeddable":true,"href":"https:\/\/www.matazone.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=345"}],"version-history":[{"count":0,"href":"https:\/\/www.matazone.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/345\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.matazone.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.matazone.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.matazone.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}