www.webdeveloper.com
Results 1 to 15 of 15

Thread: Javascript submit() won't submit

  1. #1
    Join Date
    Feb 2011
    Posts
    8

    Javascript submit() won't submit

    I have used this same code elsewhere and it worked as expected. I must be overlooking a semicolon or something, any ideas?

    Code:
    <html>
    <head>
        <title>FAMembers.Net - TV Spots for Test</title>
        <script type="text/javascript">
            function VideoTrackNLog(videoname, filename){
                frmVideoTrackNLog.videoname.value = videoname;
                frmVideoTrackNLog.nextpagename.value = filename;
                frmVideoTrackNLog.submit();
            }    
        </script>
    </head>
    <body>
        <p><b>View New TV Spots for Testing</b></p> 
        <p>
        <a href="mms://streaming.ccaglobal.com/flooringamerica/January_Free_TV_Promotion.wmv" onclick="VideoTrackNLog('Best Practices 5','streaming.ccaglobal.com/flooringamerica/January_Free_TV_Promotion.wmv');">January Free TV Promotion</a><br/>
        </p>
        <form id="frmVideoTrackNLog" name="frmVideoTrackNLog" action="/FAMediaTracker.asp" method="post">
            <input type="hidden" name="videoname" value="default" />
            <input type="hidden" name="nextpagename" value="default" />
        </form>
    </body>
    </html>

  2. #2
    Join Date
    Jan 2008
    Location
    Florida
    Posts
    1,227
    try document.frmVideoTrackNLog.submit();

  3. #3
    Join Date
    Feb 2011
    Posts
    8
    Thanks Yamaharuss! But still a no go. Still goes to the anchor tag and fires the javascript but does not submit to next page.

  4. #4
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    Thought I had something. I don't.

    ^_^

  5. #5
    Join Date
    Feb 2011
    Posts
    8
    Thanks for the thought!

  6. #6
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    <a href="mms://streaming.ccaglobal.com/flooringamerica/January_Free_TV_Promotion.wmv" onclick="VideoTrackNLog('Best Practices 5',this.href);">January Free TV Promotion</a><br/>

  7. #7
    Join Date
    Feb 2011
    Posts
    8
    Hey WolfShade. Not sure that helps. If it does help I'm not sure why it would help as the second parameter could be any value. The submit is supposed to submit to /FAMediaTracker.asp. the value in the second parameter is a filename that will be stored in a tracking database and should be inserted into the form frmVideoTrackNLog and submited to the next page where it should update the databse and then return.

  8. #8
    Join Date
    Dec 2005
    Posts
    2,984
    I'm not even sure why the rest of the code works, but it does so whatever I guess. You need to submit the actual form element.


    Code:
    document.getElementById('frmVideoTrackNLog').submit();
    I've switched careers...
    I'm NO LONGER a scientist,
    but now a web developer...
    awesome.

  9. #9
    Join Date
    Feb 2011
    Posts
    8
    aj_nsc thanks for the idea. That doesn't submit the form either. I have tried many different ways to address the form, like document.forms[0].submit() and document.forms['frmVideoTrackNLog'].submit() and the like. It seem that there is something wrong with the form. Where I use this code elsewhere it works fine. If I code onclick="frmVideoTrackNLog.submit();alert();" the submit doesn't happen but the alert does.

  10. #10
    Join Date
    Feb 2011
    Posts
    8
    BTW a button with onclick="frmVideoTrackNLog.submit();" within the form will submit it

  11. #11
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    When it's not working, it _should_ give you a JavaScript error. Did you look to see what the error is/was?

    ^_^

  12. #12
    Join Date
    Feb 2011
    Posts
    8
    No error, the submit just doesn't happen

  13. #13
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    In which browser are you testing? IE should give you a yellow triangle with a black exclamation mark, down lower left corner of browser; double click it to see the error message. FF doesn't do much unless either A) FireBug is installed and active, or 2) you open the Error Console window. If it's not submitting AND not giving an error message, then the submit isn't even being called; the event is not triggering.

    ^_^

  14. #14
    Join Date
    Feb 2011
    Posts
    8
    I am testing ith IE 8 and the developer tools, FireFox 3.6 and Firebug, Google Chrome 9, Opera 11 and Safari 4 which BTW it works in Safari. Go figure.

  15. #15
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    If neither IE or FF are giving an error message, then either the function works and does absolutely nothing (unlikely), or the page is being reset before the error message can be displayed. Still, even in that situation FF's Error Console will keep a record of it, and FireBug will notice it, too.

    IDK.

    ^_^

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles