Results 1 to 5 of 5

Thread: FireFox: submitting forms with Javascript

  1. #1
    Join Date
    Jun 2005
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default FireFox: submitting forms with Javascript

    I have various forms (using ASP as the backend) which simply will not submit with FireFox when using a "button" element with onclick="document.myform.submit();".

    Does anyone know what i am doing wrong or if there is some other way you are meant to code it for FireFox?

    All works perfectly in IE.

    I can post more code if you need it.



    Cheers!

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Try giving it an ID and submitting with document.getElementById("id").submit()
    or document.forms[0].submit
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jun 2005
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    A late reply i know but i have been away. Anyway, back to the problem. Unfortunately this still does not work, with either method.

    Here is some of the code:
    PHP Code:
    <form name="s1_2" id="s1_2" action="s1_2.asp" method="post">
    <
    input type="hidden" name="a" id="a" value="U">

    <
    input type="button" name="Back" value="<< Back" onclick="document.s1_2.a.value='P';document.s1_2.submit();" style="width:80px" />&nbsp;&nbsp;&nbsp;
    <
    input type="submit" name="Next" value="Next >>" style="width:80px" />

    </
    form
    As said before this all works fine in IE and even when i change it to:
    document.getElementById('a').value='P';
    document.getElementById('s1_2').submit();

    still nothing happens in FireFox - just nothing!

    I just don't understand - how can one then use an image or something to submit forms etc in FF?

    Please can someone shed some light on this for me?

    Many thanks.

    PS the "a" field is used so the asp page knows whether to go forwards or back through a sequence of pages... hence why i need to be able to change that as well - not just submitting the form, but it is all the same problem.
    Last edited by mattster; 08-17-2005 at 12:22 PM.

  4. #4
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by mattster
    [...]
    PHP Code:
    <form name="s1_2" id="s1_2" action="s1_2.asp" method="post">
    <
    input type="hidden" name="a" id="a" value="U">

    [...] 
    [...]

    PS the "a" field is used so the asp page knows whether to go forwards or back through a sequence of pages... hence why i need to be able to change that as well - not just submitting the form [...].
    You don't need to do that at all. Buttons can be successful controls as well as text boxes, and the like. Name both buttons something sensible, like 'direction', and then check the value on the server. You can then omit the hidden field, probably the name and id attributes on your form element as well, and this thing becomes a non-issue.

    As for the original problem, I can't replicate it, so I can't suggest a reason, or a solution. If you want either, post a URL to a small test page that demonstrates the issue.

    Mike

  5. #5
    Join Date
    Jun 2005
    Posts
    33
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hmm - i feel like a right fool! I had stupidly disabled Javascript in FF a while back whilst testing and forgot to turn it back on.

    It works and always has done!

    Cheers for your help and sorry to have wasted your time.

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
  •