Results 1 to 7 of 7

Thread: Syntax Error problem not activating javascript function

  1. #1
    Join Date
    Apr 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Syntax Error problem not activating javascript function

    I've been staring at this for a few hours and I am going mad. I am getting an error in Internet Explorer saying that there is a Syntax Error at Line: 52, Char: 34, but there is only 32 characters in the line. The offending line and lines around it are (I have added line numbers for clarity):

    47 <html>
    48
    49 <head>
    50 <script language = "JavaScript">
    51
    52 function frmShiftInfo_onsubmit()
    53 {
    54 alert("in frmShiftInfo");
    55 var form = document.frmShiftInfo;

    I had added line 54 in to see it was reaching the function; it wasn't. I am using this to call it:

    <form action="UpdateHead.asp" method="post" name="frmShiftInfo" onsubmit="return frmShiftInfo_onsubmit()">

    It had been working and I am unsure what has changed. On the same page is an onchange function, it is no longer working. The odd thing is that other page's javascript functions work with very similar code, so I am perplexed.

    Any ideas?

    Thanks,
    Mark.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Idea, but not a definite answer... just a random guess.

    Since JS functions use () and get stuff from the page input into those...

    what if it is seeing the line as longer, like function frmShiftInfo_onsubmit(whateverwasputinheresothisislongnow)

    that would give you enough characters...

    Or... maybe its a more general problem.... a loop error, or a dead end, or something. php gives odd errors when this happens and its something you just gotta know... it won't tell you if you've got a bad loop, etc. Maybe something like that....

    sorry I can't help more.



    Note: I'm taking a stab in the dark with the above guess. Someone will probably correct me (if I'm wrong), so don't worry if what I'm saying doesn't help... just a random guess.
    Last edited by djr33; 04-01-2006 at 07:13 AM.

  3. #3
    Join Date
    Apr 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks, but I don't think it is that.

    The when the function is called there aren't any variables in the brackets; unless javascript puts stuff in there that is not visible (I was unaware it did). Good idea about the characters though.

    Re: loops. There aren't loops in around the start or end of the form, although there are ASP driven loop wholly inside the form (but they would have done their work before the function is activated). Also, there aren't any loops in the functions; just if statements.

    Not sure about the dead end though. There is only one path through the pages because the design requires it.

    Thanks for your ideas,
    Mark.

  4. #4
    Join Date
    Mar 2006
    Location
    UK, warwickshire
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I might be something to do with
    Code:
    onsubmit="return frmShiftInfo_onsubmit()">
    IE is strange it might be "return" causing the error, proberly not but give it a shot

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

    Default

    No.
    Most likely, it's line 55:
    Code:
    var form = document.frmShiftInfo;
    Try:
    Code:
    var form = document.forms['frmShiftInfo'];
    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!

  6. #6
    Join Date
    Apr 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for everyone's help, but this comes down to stupidity, lack of oxygen and lack of sleep.

    IE was saying there was an error at line 52, I forgot that it only sees the HTML. So line 52 was actually line 97 (the problem was in a completely different function), because there is 45 lines of ASP at the start, oops.

    Amazing what a bit of sleep will do. Next time I will rest before panicking.

    Thanks again,
    Mark.

    (By-the-way, the problem was pretty simple. I had some big if statements with a lot of ||, I forgot to put () around each item.)

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

    Default

    Heh, whoops.
    But you still ought to use the document.forms collection.
    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!

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
  •