Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2004
    Location
    Tampa
    Posts
    223
    Thanks
    23
    Thanked 0 Times in 0 Posts

    Form submitting when clicking in the input box

    I have a form on a page and it is one input box and one image submit button. The button comes before the form on the page. The problem I am having is that the form submits itself as soon as I click in the input box without even clicking on the submit button. It doesn't happen in IE though. Only Firefox and Safari.

    Any help on this would be greatly appreciated.

    Thank you!

    Code:
    <div id="toplogo"><form action="<?php $_SERVER['PHP_SELF']; ?>" method="POST">
      <label>
      <input name="submit" type="image" src="images/button_search.jpg" alt="Search Now" align="top" width="29" height="9" style="padding-top: 18px; padding-right: 10px; background-color: none;" tabindex="2">
    <input name="textfield" type="text" id="textfield" size="27" tabindex="1" class="searchbox">
      </label>
    </form>
    </div>

  • #2
    Regular Coder
    Join Date
    Jul 2004
    Location
    Tampa
    Posts
    223
    Thanks
    23
    Thanked 0 Times in 0 Posts
    Okay, I noticed that if I move the image submit button to the other side of the input box it works fine in IE / FF and Safari. Anyone know a way that I can have the submit button first in FF and Safari without it submitting as soon as I click in the first input box?

  • #3
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Remove the label, you aren't using it properly anyways. Its also causing your issues because the label brings focus to the first element that is within it.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • Users who have thanked _Aerospace_Eng_ for this post:

    dprichard (01-07-2008)

  • #4
    Regular Coder
    Join Date
    Jul 2004
    Location
    Tampa
    Posts
    223
    Thanks
    23
    Thanked 0 Times in 0 Posts
    Thank you. Yeah, I was going back and forth between textmate and dreamweaver. I guess dreamweaver threw that in and I didn't even notice it.

    That fixed the problem!


  •  

    Posting Permissions

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