SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Drop-down menu with image as Submit button

    Hello,

    I have a basic drop-down menu that works fine with a normal Submit button but won't work if I replace the button with an image.

    This is the JavaScript in the <head>:
    Code:
    <script type="text/javascript"> 
    <!-- 
    //Hide from Java Script
    function goToPage2() 
    { 
    PageIndex2=document.form2.select2.selectedIndex 
    
    if (document.form2.select2.options[PageIndex2].value != "none") 
    { 
    location = document.form2.select2.options[PageIndex2].value 
    } 
    } 
    //--> 
    </script>
    And this is my drop-down menu code:
    Code:
    <form name="form2" id="form2" action="">
    <select name="select2" size="1">
      <option>Quick Links</option>
      <option value="page1.html">Page 1</option>
      <option value="page2.html">Page 2</option>
      <option value="page3.html">Page 3</option>	
    </select>		  	  
    &nbsp;<input type="button" name="B2" id="B2" value="Go" onclick="goToPage2()" />						
    </form>
    When I change the line with the Submit button to this below, it stops working:
    Code:
    <input type="image" src="graphics/go.gif" align="top" name="B2" id="B2" value="Go" onclick="goToPage2()" />
    Can anybody see why it's not working?

    Julia

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,053
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    image submit

    If it works in Firefox but not other browsers, it may have something to do with the way browsers handle image input submits http://www.sitepoint.com/forums/show...81#post3627681

  3. #3
    Non-Member
    Join Date
    Aug 2007
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should use
    <input type="button" style="background-image: url(graphics/go.gif);" align="top" name="B2" id="B2" value="Go" onclick="goToPage2()" />

  4. #4
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the suggestions!

    Julia


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •