Jump to content

unknown bug in my js


hgmme@wa

Recommended Posts

Well I've been trying to figure this out but to no avail at all...I'm making a page for adding users, and when you first load the page it loads a list of "groups" with a check box for each group. There is also a drop down box to select the users status, which starts with "Select Status", and the options are:

  • Select Status
  • 1 (Administrator)
  • 2 (Director)
  • 3 (Volunteer)
  • 4 (User)

So when the person adding a user selects 1, or 2, and check a box not much of interest happens, but if a user selects 3 or 4 (4 is actually currently disabled, since I'm not fully ready to build support for it) then checks a check box it then uses ajax to display the list of categories under that group and deselects the group check box, and naturally their is a check box for each category. Why I do that is because a level 1 user is actually above groups, and 2 is in charge of a group, but 3 and 4 are to be part of a category. There is also an image of an arrow pointing up to make the categories disappear. Now if you select the users status then check and uncheck a box, or collapse the list of categories, every thing works fine. But where things are acting goofy is where you check 1 or more boxes then set the users status to 3 or 4. You can go the other way no problem (meaning if you set the status to 3, then select several groups, making it list categories, then change the status to 1 or 2, it then collapses them fine). The web page is: www.ctkanacortes.com/adduser2.php (I have removed all the php involved in checking the content, and adding it to the database on that page, since naturally the real page requires a registered user (level 3 or better).The js function used when the status is change is called: chStatus(). Define on line: 33, the code for when a level 3 user is selected is on line: 64.When a check box is checked, then the function: check() is called. Defined on line: 103. When the status level is 3 then the function: extend() is called. Defined on line: 143. The function to remove the listed categories is called: retract(). Define on line: 164.Couple of notes: There is a hidden <input> for the drop down that contains its former value. There is also a hidden <input> field for every group that is listed, and it either says: "retracted" or "extended", depending on whether or not the status is 3 or 4 and a group is expanded into categories.Any other help info I can provide, I would be happy to do. (Might be U.S. Monday before I can though), thanks.

Link to comment
Share on other sites

I was really scarred there for a couple of minutes, cause I thought I posted what will follow this, as a reply but I had actually edited my post! :) But I managed to find it in my cache, thank Jesus.

(Might be U.S. Monday before I can though)
Which is today people! :) I know it's a lot of stuff to go through :mellow:, that's why I delayed asking for help for so long...
Link to comment
Share on other sites

I'm not really sure what you're looking for here, but I did notice that there is an event handler assigned to the change event of the drop-down menu:

<select id="statusIN" onchange="chStatus()" name="status">

But the javascript declares that function using a different name:

function chSstatus() {

Link to comment
Share on other sites

Woops, new I should have checked to make sure the stuff that should be working is working, cause I had made a few small modifications just before posting including modifying that function name.

I'm not really sure what you're looking for here, but I did notice that there is an event handler assigned to the change event of the drop-down menu:
When your in Firefox, and you check two or more boxes then change the status to '3 (Volunteer)' it should take those checkboxes which represent a 'group' and display the 'categories' for those 'groups', with a checkbox for every 'category'. But instead depending on the browser, it will either show the categories for the top checked group, and none of the others or it will display the categories for the top checked group and display the categories for the other groups three times. In the first mentioned instance I know it does in fact send to the server for categories belonging to all the checked groups, and in the later instance it only sends for them once.That's what I'm wanting help to fix.EDIT: What it should do:
  1. You load the page. (no brainer)
  2. You check 1 or more groups.
  3. You change the status from 'Select Status' to 3 (Volunteer)' or 4 ( User)'.
  4. Then it should list the categories for all groups, once. (not all the groups have a category, but it should still show the retract arrow)

Link to comment
Share on other sites

So I've narrowed it down to being the "Extend()" function, by defining a variable that equals 1 before the function, then alerting it's value from in the function, and adding 1 to the variable, so I know that the function is called the proper number of times, then I defined another variable before the "stateChanged1()" (again equals 1) and alerted its value from within the if stateChanged == 4/complete statement. Which told me that statement will either prove to be true never, once, or three times, depending on how you hold your nose and what browser your using. (again I haven't yet done much testing in IE, just Firefox and Safari) (it should be true once, though you should know that)Here is the code for the extend() function (the stateChanged1() function is within extend()):

	var sc = 1;	function extend(theID, type, ID) {		var status2 = document.getElementById('E' + type + ID);		xmlHttp=GetXmlHttpObject()		if (xmlHttp==null) {			alert ("Browser does not support HTTP Request");			return;		}		alert('sc = ' + sc);		sc++;		var url = "<?php echo $config_basedir; ?>" + "adduser.php";		url=url+"?do=listCats&groupID=" + ID;		url=url+"&sid="+Math.random();		xmlHttp.onreadystatechange=stateChanged1;		xmlHttp.open("GET",url,true);		xmlHttp.send(null);		var num = 1;		function stateChanged1() {			if ( xmlHttp.readyState == 4 || xmlHttp.readyState == "complete" ) {				status2.value='extended';				document.getElementById('V' + ID + 'LI').innerHTML+=xmlHttp.responseText;				document.getElementById(theID).checked=false;				alert('hello ' + num);				num++;			}		}	}

I left the variables, and alerts I used to make my discovery in it. If you want to see the page with those variable/alerts then go to www.ctkanacortes.com/adduser3.php, and with out those variable/alerts go to www.ctkanacortes.com/adduser2.php.And again the problem is when you check more than one group, then change the drop down (status) to 3. When you do that it's suppost to extend all the checked groups to display the categories once. (if all it shows is an arrow pointing up then there aren't any categories in that group)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...