SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Member
    Join Date
    Sep 2006
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    submit() not working with IE

    Hi, I've a PHP page with a form. Outside the form I've a link like this
    <a href="javascript:void(0);" onclick="document.forms['cvSearch'].submit();">send</a>
    It works well with FF but not with IE 6. I've even tryed document.cvSearch.submit(); but nothing. The strange thing is that if I create a simple page with a form and a link like that it works! I really can't understand what it could be. Any suggestion is very wellcome.
    Thank you.

  2. #2
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to show more code. Also, why do you use a link to submit the form, when you aren't really using it to navigate to another page? You might want to use a button instead. Or any other element and style it with CSS.

  3. #3
    SitePoint Member
    Join Date
    Sep 2006
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've attacched the whole resulting page. The link is at line 1211 with text "Inserisci nel progetto".
    Attached Files Attached Files

  4. #4
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well we've all seen this one before...without looking at your code (it's pending still)...

    You have a form element with name="submit"

    This overwrites the submit method of the form element.

  5. #5
    SitePoint Member
    Join Date
    Sep 2006
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jim, I really hoped it was like you said but unfortunately there's no form element with the name="submit" nor type="submit". Anyway I think this could be a good direction it must be something like that. For the submission of the form I've images could it be that?

  6. #6
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you have no form elements with name="submit" (including input type=image) then no its something else.

    Still pending...

  7. #7
    SitePoint Member
    Join Date
    Sep 2006
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jim I've posted the code just before your first post, could you give it a look?
    Thank you.

  8. #8
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <a href="pageForPeopleWithoutJavascript.htm" 
    onclick="document.forms['cvSearch'].submit(); return false;">
    send</a>
    Note: your choice of methods for submitting a form is a bad one.

  9. #9
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm well I tried the code you posted, I put scriptaculous and prototype in the correct place (the other JS libraries appear to be your own and I dont have access to em) - and the form DID submit, so maybe you've got something weird going on in your libs?

  10. #10
    SitePoint Member
    Join Date
    Sep 2006
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok jim, I'll try check my libs.

    7stud which other method do you suggest in situations like this?

  11. #11
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The preferred way is something along the lines of

    <input type="submit" value="send" />

  12. #12
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can style a submit button with css to look just like text if you want as well. See here:

    http://www.webreference.com/programming/css_stylish/

    7stud which other method do you suggest in situations like this?
    In situations like what? A situation where you want to present the user with a way to submit a form? Submit buttons are used to submit forms. In addition, you should never use "javascript: ..." in your html.

  13. #13
    SitePoint Member
    Join Date
    Sep 2006
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 7stud View Post
    In situations like what? A situation where you want to present the user with a way to submit a form?
    I mean a situation in which the submission needs to be done outside the <form> tag.

  14. #14
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by nicoladf View Post
    I mean a situation in which the submission needs to be done outside the <form> tag.
    Display the following in your browser:
    Code:
    <!DOCTYPE html
      PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml" 
      xml:lang="en" lang="en"><html>
    <head><title></title>
    
    <head><title></title>
    
    <style type="text/css">
    
    .myClass {
    	position:relative;
    	top: 10em;
    	background-color: pink;
    	border: 0;
    }
    
    </style>
    <script type="text/javascript" >
    
    </script>
    </head>
    
    <body >
    
    <form name="f" method="post" action="">
    	<div>name:<input type="text" name="" id="" /></div>
    	<div>some text inside the form
    	<input class="myClass" type="submit" value="Submit" />
    </form>
    
    <div>some text outside the form</div>
    
    </body>
    </html>
    If a user has js disabled, how are they going to be able to submit the form with your link?

  15. #15
    SitePoint Member
    Join Date
    Sep 2006
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    7stud I'm aware of this but I'm in a lucky case since this page is inside an application so JS enabled will be a requirement.

  16. #16
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Then see my first post, and change the href to href="".


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
  •