cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Apr 2013 05:45 PM |
This function:
[Assuming everything is defined above] function CreatePerson(Name, Gender, Type) { Name = Name || ""; Gender = (Gender==null) ? 0 : parseInt(Gender); Type = (Type==null) ? 0 : parseInt(Type);
if(AllPeople.length == MaxPeople) return false; f(GetPerson(Name) != false) return false; if(!TestCreation(Name, Gender, Type)) return false; Test = new Person(Name, Gender, Type) AllPeople.push(Test); return true; }
Does work when it's called normally, but when it's called with a button, (internet explorer debug error) the error: Object doesn't support this action (WHERE Test = new Person)
Team viewer if you don't understand |
|
|
| Report Abuse |
|
|
Maradar
|
  |
| Joined: 06 Mar 2012 |
| Total Posts: 4478 |
|
|
| 26 Apr 2013 05:47 PM |
Likely since you did not define where it goes. I glanced over it and only know part of JavaScript. So, if I'm wrong, I suppose I'll be wrong.
ProPAIN |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Apr 2013 05:50 PM |
I can show you via teamviewer or here's an explanation:
-Create account from inside the script tag (not in a function) it works fine. -When I do the action within a function, it gives me that error.
[Example: < SCRIPT >
CreateAccount(x,y,z); >>True/False
function MakeAccount(x,y,z) { if(CreateAccount(x,y,z)) >>null or N/A or nothing else >>false } |
|
|
| Report Abuse |
|
|
|
| 26 Apr 2013 05:51 PM |
> f(GetPerson(Name) != false)
if(GetPerson(Name) != false)* |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Apr 2013 05:51 PM |
| I accidentally removed the i when copying this, but it's there normally. |
|
|
| Report Abuse |
|
|
|
| 26 Apr 2013 05:53 PM |
| oh. if it isnt fixed in about two hours, then i can try to help over teamviewer. im going out to eat soon. ill check up on the thread when i get back. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Apr 2013 05:54 PM |
k
It's a weird problem, I'll try to explain a general view of it:
-Function -Calls function via < SCIRPT > [returns true OR false] -Calls function via another function [returns false OR nothing...] |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Apr 2013 06:00 PM |
OhhEmmGee-e, What do I see-e;
No problems in script, JavaScript has tripped; (wut)
If someone won't help me, I will cry with thee |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Apr 2013 06:29 PM |
Figured something out:
It breaks anytime the function "GetPerson" or if not that, "Update" is called
function GetPerson(Name) { for(i=0; i < AllPeople.length; i++) { if(Name.toLowerCase() == AllPeople[i].Name.toLowerCase()) return AllPeople[i]; } return false; }
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Apr 2013 06:42 PM |
The source of the problem (finally found, IDK what's wrong)
if(TestCreation(Name, Gender, Type)) { if(Type == 8) { window.alert("You can not change the person to this type"); return; } Person = GetPerson(Name); Person.Gender = Gender; Person.Type = Type; UpdatePeopleField(Name); window.alert("Updated"); } else window.alert("Make sure the gender and type is valid");
I can make all the accounts I want, but if I update their details, the account creation stops working but the updating still works... |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Apr 2013 06:46 PM |
Nope, the actual source is:
(Note: AllPeople is an array) function GetPerson(Name) { for(i=0; i < AllPeople.length; i++) { if(Name.toLowerCase() == AllPeople[i].Name.toLowerCase()) return AllPeople[i]; } return false; }
It apparently always works, but when used by the UpdatePerson function, something goes wrong... |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Apr 2013 06:50 PM |
Fixed
Problem
Variables Name (Person) will overwrite the Person function All I did was change the function name and it worked =D |
|
|
| Report Abuse |
|
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Apr 2013 06:55 PM |
| ikik, I should of though of that... |
|
|
| Report Abuse |
|
|
|
| 26 Apr 2013 06:57 PM |
it doesnt seem that hard to forgot three letters.
anyway, is it fixed yet? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Apr 2013 07:02 PM |
| Yes, and it works perfectly, I'm just rewriting the code now to make it nicer and more efficient (I always do this after I 100 line script or more is finished). |
|
|
| Report Abuse |
|
|
|
| 26 Apr 2013 08:05 PM |
| Are you incapable of going to a JS helping forum? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|