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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Regular Coder
    Join Date
    Jan 2004
    Location
    Port Huron, MI, U.S.A.
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    syntax error-CAN'T FIND IT

    I have a script that is supposed to show you how something (an ad in this case) would look with different colors. However, I'm getting the "syntax error" error and I cannot figure out what it is. This is causing the script to not function. The script is very simple and the document is as follows:

    Code:
    <html>
    <heaD>
    
    <style>
    .Main {width:350px;height:470px;border:3 outset steelblue;margin:8 8 8 8;filter:shadow(color=blue,direction=235,strength=3) progID:DXImageTransform.Microsoft.gradient(startcolorstr=#009090,endcolorstr=#001010,gradienttype=0);font-family:Times New Roman;color:white;overflow:hidden;font-weight:bold;text-align:center}
    h1 {text-transform:UpperCase}
    input {color:blue}
    </style>
    
    <script language="Javascript">
    function Change(C,B) {
    var it=document.getElementById("TEST").style;
    it.color=C;
    it.filter="glow(strength=2,color="+B+")"
    
    
    
    }
    
    function px(evt) {
    //e=(evt)?evt~
    var x=event.clientX;
     var y=event.clientY;
    window.status=x+','+y
    }
    document.onmousemove=px
    </script>
    
    
    
    </head><body bgcolor=white>
    <div class="Main">
    <font size=2>"Port Huron's Leader in Quality Locksmithing"</font>
    <BR>
    <h1>Noble<h1>
    <font size=3>LOCKSMITH SERVICE, INC.<BR>
    Commercial<sup>.</sup>Residential<BR>Domestic&amp;Foreign<BR>Lockouts&amp;Safes<BR></FONT>
    <font size=1>**High Security Specialist**</font>
    <Table border=0 bgcolor=""><TR><TH><IMG>
    <BR><font size=1 color=black><small>R. Noble, CPL</small></font>
    
    </th><TH>
    <div id="TEST" style="width:186;height:62;color:red"><font size=2>The ONLY Bonded, <BR><I>Certified Professional Locksmith</i><BR>
    serving St. Clair and<BR> Sanilac Counties</div></th></tr></table>
    
    <div style="text-align:left;width:340px"><div style="text-align:center;color:white"><div style="width:339px;height:1px;overflow:visible;filter:dropshadow(color=black,positive='true',offx=1,offy=0)">
    <font size=2>(810)</font><BR>
    <font size=7>385-9329</font></div>
    <BR>
    <table border=0 bgcolor=""><TR><TH>
    <IMG><IMG><BR><IMG><IMG></th><TH style="color:black">
    <font size=1>2670 Grace Road,<BR>Fort Gratiot</font></th></tr></table>
    
    </div></div></div>
    <form name="FormY"><table><TR><TD>
    Text color:<BR>
    Border Color:</td><TD><input type=text name="C"><BR><input type=text name="B"></td></tr></table>
    <input type=button style="border:steelblue 3 outset;color:white;font-style:italic;filter:progID:DXImageTransform.Microsoft.wave(add=1,phase=22,freq=7,strength=0,lightStrength=100);background-color:navy" onClick="Change(window.document.forms["FormY"].C.value,document.forms.FormY.B.value)" value="TRY">
    
    </form>
    Any help is appreciated; thanks in advance!
    Oh, was I supposed to put something here? ........

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rather easy to find if you turn on error reporting...

    Line 59: onClick="Change(window.document.forms['FormY'].....

    .....Willy

  • #3
    Regular Coder
    Join Date
    Jan 2004
    Location
    Port Huron, MI, U.S.A.
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Cool, now I know the problem, so thanks! I wasn't able to determine the problem, though, because MY error report read Line 65, which contained absolutely nothing.
    Oh, was I supposed to put something here? ........

  • #4
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    I would suggest you to use moz or op for JavaScript bugtracking, or at least downloading the Microsoft Script Debugger. The JavaScript Consoles of both moz and op are far better than the iew bug reporting facilities, and the additional help you get from their other web developer tools is fabulous.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #5
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Bobo
    I wasn't able to determine the problem, though, because MY error report read Line 65, which contained absolutely nothing.
    I don't know why everyone seems to claim that their error line-number is wrong in IE... maybe it's your editor, because, when I use "Go To..." in Notepad.exe, it is always accurate.
    *this message will self destruct in n-seconds*

  • #6
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    625
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rather easy to find if you turn on error reporting...
    I prefer chanting, "there's no place like home," while clicking my heals 3 times in rapid succession...works for me.


    -james
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Quote Originally Posted by Willy Duitt
    Rather easy to find if you turn on error reporting...

    Line 59: onClick="Change(window.document.forms['FormY'].....

    .....Willy
    or simply use this.form since the button where it is called is in the same form as the other fields.

    <input onclick="Change(this.form.C.value, this.form.B.value)">
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #8
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by glenngv
    or simply use this.form since the button where it is called is in the same form as the other fields.

    <input onclick="Change(this.form.C.value, this.form.B.value)">

    or simply use onclick="Change(C.value, B.value)", because JS is smart that way...
    *this message will self destruct in n-seconds*

  • #9
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    That also works but only do when used inline. When using C.value or B.value inside a function or anywhere not inline to an element, it will only work in IE so it encourages bad programming practice. So to avoid confusion, it's recommended to use the absolute reference.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #10
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If it works inline, why not use it inline?
    Not knowing the difference is bad programming practice IMO.
    me recommends it
    *this message will self destruct in n-seconds*

  • #11
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    In fact, good coding practice is, among other things:
    - Use standards where applicable.
    - Never rely on anything implicit.
    - Keep different languages separated.

    Recommending inline use and using that syntax breaks those mentioned points.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #12
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Why not rely on implicit refs? Do they not work for a reason; is that not by design?
    *this message will self destruct in n-seconds*

  • #13
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Let me explain to you why relying on implicit things may be a bad thing to do by giving you two examples:

    Relying on semicolon insertion:
    Code:
    // How you want it to be
    a = b; // => b
    (2+c)*a; // => [return value of ((2+c)*b)]
    
    // How you write it:
    a = b 
    (2+c)*a// => [return value of (b(2+c)*a)]
    Relying on autocoercion for object detection:
    Code:
    // What you want:
    function each(coll,action){
        var
            i=0,
            elm;
        while(elm=coll.item(i++)) // returns null if element is undefined
            action(elm);
    }
    
    // What you write:
    function each(coll,action){
        var
            i=0,
            elm;
        while(elm=coll[i++]) // Gives an error since the property is undefined 
            action(elm);
    }
    See what problems relying on implicit behaviors may cause if you're unwary?
    Last edited by liorean; 08-30-2004 at 01:49 PM.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #14
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Indeed, you have to know what you're doing to use implicitness correctly... but it can be used correctly, and in the case of elements, I see no fundamental difference between that and taking advantage of the global window object (which seems to be a widely accepted ommission)... besides, once you get it right, there you have it (something new in your bag o' tricks).
    *this message will self destruct in n-seconds*

  • #15
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    But now you forget the third and first points.

    Keep different languages separate:
    The thing that allows you to use Change(C.value, B.value) instead of Change(this.form.C.value, this.form.B.value) is that the scoping of inline script in event handlers does not match the scoping of said script as defined from within JavaScript. It's implicit because of a crossing between HTML and JavaScript changes the way JavaScript works. What you SHOULD use is something that would work independent how it's defined, and that means that you need to explicitly state the this.form part.

    And again, the first point:
    You might use Change(C.value, B.value) in IEW and still find it works just fine, even when set from JavaScript. However, you are then relying on a proprietary behavior that other browsers don't have.




    Edit: What do you mean, window object ommission? The Global object is the surface scope, and identifier resolving goes from deepest to shallowest scope. That all variables in the global scope are properties of the Global object is a core language feature. The window object is merely a variable pointing to the Global object. It could be done without very easily, for example by using the this property of any scope not bound to an object, including the global scope itself. Let's ponder a browser without the window object. How does one emulate the window object? Simple, just watch:
    Code:
    var window=this;
    Last edited by liorean; 08-30-2004 at 03:56 PM.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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