Results 1 to 6 of 6

Thread: Javascript question

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Dallas, Texas
    Posts
    62

    Javascript question

    Ok heres what i got, i am getting an error 'cannot assign to a function result' whenever i run this function .. I am gonna post only the first half of the code cuz it is kind of long ,
    Code:
    			sofar="______";
    			thepot="";
    			s="";
    			p="";
    			theword="";
    			l=0;
    		function HangMan() {
    			theword="daniel";
    			l=theword.length
    				if (sofar=theword) {
    					Finish();
    				}
    			userin= prompt('Guess a lettter');
    //The For Loop is where it says its happening i have never
    // seen this error before so i dont know what it means   
                                                   for (x = 1; x < l; i++) {
    				 if (theword.substring(x,1)=userin) {
    					sofar+=theword.substring(x,1);
       					RefVar();
    				}
    			}
    If anyone could help i would greatly appreciate it..

    oOblackorbOo

  2. #2
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    I think it is your "=" signs. "=" by itself is used to set something to something else. What you want is "==".

    so it would look like this on the if statements.
    Code:
    if (theword.substring(x,1)==userin)
    www.RealisticGraphics.net

    Running VS.Net Enterprise & VB 6

    Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML

    MSN Messenger: kmsheff

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Dallas, Texas
    Posts
    62
    Now i am getting 'Object Expected' at this line of code
    Code:
    userin=prompt('Guess a lettter');
    I fix one thing then its on to another!

  4. #4
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655
    Actually I think your error is occuring at the start of the For loop.

    for (x = 1; x < l; i++)

    The i++ should be x++

    Try this instead and let me know if you need anything else:

    for (x = 1; x < l; x++)
    www.RealisticGraphics.net

    Running VS.Net Enterprise & VB 6

    Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML

    MSN Messenger: kmsheff

  5. #5

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Dallas, Texas
    Posts
    62
    now i am getting the first error again at
    if (theword.substring(x,1)==userin) {
    Well at least thats where IE Says it is

    Dang IT!

  6. #6

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Dallas, Texas
    Posts
    62
    it looks like its only happening when i type in the letter 'a'

Posting Permissions

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



Click Here to Expand Forum to Full Width