Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

CDML & conditional value lists


This topic is 7880 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Jeff,

Here is the next installment wink.gif

<head>

	<title>Array Test</title>

	<meta name="generator" content="BBEdit 7.0.1">

	<script>

		// Declare Variables

		var aDept = new Array();

		var aPosn = new Array();

		var aEmp = new Array();

		var i = 0;

		var j = 0;

		var k = 0;

		// Select all values

		[FMP-InlineAction: -db=employees.fp5, -lay=web, -sortfield=department, -sortfield=position, -sortfield=emp_name, -max=all, -findall]

		// Assign to Arrays

		[FMP-Record]

		aDept[i++] = "[FMP-Field: department]";

		aPosn[j++] = "[FMP-Field: position]";

		aEmp[k++] = "[FMP-Field: emp_name]";

		[/FMP-Record]

		// Constuct an Array of the Unique Department names by using a ValueList	

		aMain = new Array();

		[FMP-ValueList:department]

		aMain["[FMP-ValueListitem]"] = "empty";

		[/FMP-ValueList]

		[/FMP-InlineAction]

		

		// Load the Main Array		

		var x = 0 ;

		var aTempPosn = new Array() ;

		var aTempEmp = new Array() ;

		for ( z = 0; z < aDept.length; z++)

			{

			sDept = aDept[z] ;

			sPosn = aPosn[z] ;

			sEmp = aEmp[z] ;

			// Add Emp while Posn is the same!!!

			if ((z == 0) || (sPosn == aPosn[(z-1)]))

				{

				aTempEmp[x] = sEmp;

				x = x++ ;

				}

			else

				{

				aTempPosn[aPosn[(z-1)]] = aTempEmp;

				aMain[aDept[(z-1)]] = aTempPosn;

				aTempPosn[aPosn[(z-1)]] = aTempEmp;				

				var aTempEmp = new Array() ;

				x = 0 ;

				aTempEmp[x] = sEmp;

				};

			};

		aTempPosn[sPosn] = aTempEmp;

		aMain[sDept] = aTempPosn;

			

		// Update Position ValueList when Department is changed.

		function selPosition()

			{

			with (document.myform)

			{

			var nIndex = department.selectedIndex ;

			var sIndex = department.value ;

			if (nIndex > 0)

				{

				// Clear the existing Options of Position and Employee

				for (i = position.options.length; i > 0; i--) {

					position.options[i] = null ; } ;

				for (i = emp_name.options.length; i > 0; i--) {

					emp_name.options[i] = null ; } ;

				for (a=1; a < 2;a++)

					{

					position.options[a] = new Option(aMain[sIndex]) ;

					position.options[a].value = aMain[sIndex] ;

					};

				}

			else

				{

				for (i = position.options.length; i > 0; i--) {

					position.options[i] = null ; } ;

				for (i = emp_name.options.length; i > 0; i--) {

					emp_name.options[i] = null ; } ;

				};

			};

			};



		// Update Employee ValueList when Position is changed.

		function selEmployee()

			{

			with (document.myform)

			{

			var nIndex = position.selectedIndex ;

			if (nIndex > 0)

				{

				// Clear the existing Options of Employee

				for (i = emp_name.options.length; i > 0; i--) {

					emp_name.options[i] = null ; } ;

				emp_name.options[1] = new Option("Employees Appear Here") ;

				}

			else

				{

				for (i = emp_name.options.length; i > 0; i--) {

					emp_name.options[i] = null ; } ;				

				};

			};

			};

	</script>

</head>

<body>Hello World....<br>

<form method="post" action="#" name="myform">

<select name="department" onchange="Javascript:selPosition();">

<option value="">Please Select a Department</option>

		[FMP-ValueList:department]

		<option value="[FMP-ValueListItem]">[FMP-ValueListItem]</option>

		[/FMP-ValueList]

</select><br>

<select name="position" onchange="Javascript:selEmployee();">

<option value="">Please Select a Position</option>

</select><br>

<select name="emp_name">

<option value="">Please Select an Employee</option>

</select></form><br>

This script sets-up the aMain array. The next part which needs to be completed is the allocation of the appropriate array elements to the ValueLists.

I don't think that I will be in Las Vegas this year frown.gif Unless I win the lotto, or I complete some of my software for Film & Television post-production. Maybe next year smile.gif

All the best.

Garry

Link to comment
Share on other sites

Hey Garry,

Well, I plugged it into the web page and booted it all up and it seems to be working (of course, with no values in the second and third popups except for the test field, it was hard to see if its working). Of course, I know that it IS working because you never do anything wrong! I can't wait for the next step. (yes, drool is actually coming out of my mouth). I'm going to chomp on this section for the rest of the night to try to understand it all. Sorry to hear that you won't be able to make NAB this year. But, you definitely have a raincheck for a show in Vegas next time you come over. Best of luck with your production software. I'm sure it's amazing and I'd like to hear more about it. Talk to you soon,

-Jeff

Link to comment
Share on other sites

Jeff,

Here it is smile.gif

<html>

<head>

	<title>Array Test</title>

	<meta name="generator" content="BBEdit 7.0.1">

	<script>

		// Declare Variables

		var aDept = new Array();

		var aPosn = new Array();

		var aEmp = new Array();

		var i = 0;

		var j = 0;

		var k = 0;

		// Select all values

		[FMP-InlineAction: -db=employees.fp5, -lay=web, -sortfield=department, -sortfield=position, -sortfield=emp_name, -max=all, -findall]

		// Assign to Arrays

		[FMP-Record]

		aDept[i++] = "[FMP-Field: department]";

		aPosn[j++] = "[FMP-Field: position]";

		aEmp[k++] = "[FMP-Field: emp_name]";

		[/FMP-Record]

		// Constuct an Array of the Unique Department names by using a ValueList	

		aMainDept = new Array();

		[FMP-ValueList:department]

		aMainDept["[FMP-ValueListitem]"] = new Array();

		[/FMP-ValueList]

		[/FMP-InlineAction]

		

		// Load the Main Arrays		

		var aTempEmp = new Array();

		var aMainPosn = new Array();

		sDept = aDept[0];

		sDeptPrev = aDept[0];

		sPosn = aPosn[0];

		sPosnPrev = aPosn[0];

		sEmp = aEmp[0];

		aTempEmp[0] = sEmp;

		var q = 0;

		var p = 0;

		for ( z = 1; z < aDept.length; z++)

			{

			sDept = aDept[z];

			sPosn = aPosn[z];

			sEmp = aEmp[z];

			// Add Emp while Posn is the same!!!

			if (sPosnPrev == sPosn)

				{

				q = q + 1;

				aTempEmp[q] = sEmp;

				}

			else

				{

				if (sDeptPrev == sDept)

					{

					aMainDept[sDept][p] = sPosnPrev;

					p = p + 1;

					}

				else

					{

					aMainDept[sDeptPrev][p] = sPosnPrev;

					sDeptPrev = sDept;

					p = 0;

					};				

				aMainPosn[sPosnPrev] = aTempEmp;

				var aTempEmp = new Array();

				aTempEmp[0] = sEmp;

				q = 0 ;

				sPosnPrev = sPosn;

				};

			};

		aMainDept[sDept][p] = sPosn;

		aMainPosn[sPosn] = aTempEmp;

			

		// Update Position ValueList when Department is changed.

		function selPosition()

			{

			with (document.myform)

			{

			var nIndex = department.selectedIndex ;

			var sIndex = department.value ;

			if (nIndex > 0)

				{

				// Clear the existing Options of Position and Employee

				for (i = position.options.length; i > 0; i--) {

					position.options[i] = null ; } ;

				for (i = emp_name.options.length; i > 0; i--) {

					emp_name.options[i] = null ; } ;

				for (a=0; a < aMainDept[sIndex].length; a++)

					{

					position.options[a+1] = new Option(aMainDept[sIndex][a]) ;

					position.options[a+1].value = aMainDept[sIndex][a] ;

					};

				}

			else

				{

				for (i = position.options.length; i > 0; i--) {

					position.options[i] = null ; } ;

				for (i = emp_name.options.length; i > 0; i--) {

					emp_name.options[i] = null ; } ;

				};

			};

			};



		// Update Employee ValueList when Position is changed.

		function selEmployee()

			{

			with (document.myform)

			{

			var nIndex = position.selectedIndex ;

			var sIndex = position.value ;

			if (nIndex > 0)

				{

				// Clear the existing Options of Employee

				for (i = emp_name.options.length; i > 0; i--) {

					emp_name.options[i] = null ; } ;

				for (a=0; a < aMainPosn[sIndex].length; a++)

					{

					emp_name.options[a+1] = new Option(aMainPosn[sIndex][a]) ;

					emp_name.options[a+1].value = aMainPosn[sIndex][a] ;

					};

				}

			else

				{

				for (i = emp_name.options.length; i > 0; i--) {

					emp_name.options[i] = null ; } ;				

				};

			};

			};

	</script>

</head>

<body>Hello World....<br>

<form method="post" action="#" name="myform">

<select name="department" onchange="Javascript:selPosition();">

<option value="">Please Select a Department</option>

		[FMP-ValueList:department]

		<option value="[FMP-ValueListItem]">[FMP-ValueListItem]</option>

		[/FMP-ValueList]

</select><br>

<select name="position" onchange="Javascript:selEmployee();">

<option value="">Please Select a Position</option>

</select><br>

<select name="emp_name">

<option value="">Please Select an Employee</option>

</select></form>

</body>

</html>

It has not been optimized. It has had some testing under certain assumptions about the data structure. It works fine; so far!

All the best.

Garry

Link to comment
Share on other sites

Jeff,

Here is a version with some space and loop optimization:

<html>

<head>

	<title>Array Test</title>

	<meta name="generator" content="BBEdit 7.0.1">

	<script>

		// Declare Variables

		var aDept = new Array();

		var aPosn = new Array();

		var aEmp = new Array();

		var i = 0;

		var j = 0;

		var k = 0;

		// Select all values

		[FMP-InlineAction: -db=employees.fp5, -lay=web, -sortfield=department, -sortfield=position, -sortfield=emp_name, -max=all, -findall]

		// Assign to Arrays

		[FMP-Record]aDept[i++]="[FMP-Field: department]";aPosn[j++]="[FMP-Field: position]";aEmp[k++]="[FMP-Field: emp_name]";[/FMP-Record]

		// Constuct an Array of the Unique Department names by using a ValueList	

		aMainDept = new Array();

		[FMP-ValueList:department]aMainDept["[FMP-ValueListitem]"]=new Array();[/FMP-ValueList]

		[/FMP-InlineAction]

		// Load the Main Arrays		

		var aTempEmp = new Array();

		var aMainPosn = new Array();

		sDept = aDept[0];

		sDeptPrev = aDept[0];

		sPosn = aPosn[0];

		sPosnPrev = aPosn[0];

		sEmp = aEmp[0];

		aTempEmp[0] = sEmp;

		var q = 0;

		var p = 0;

		nDepLen = aDept.length;

		for ( z = 1; z < nDepLen; z++)

			{

			sDept = aDept[z];

			sPosn = aPosn[z];

			sEmp = aEmp[z];

			// Add Emp while Posn is the same!!!

			if (sPosnPrev == sPosn)

				{

				q = q + 1;

				aTempEmp[q] = sEmp;

				}

			else

				{

				if (sDeptPrev == sDept)

					{

					aMainDept[sDept][p] = sPosnPrev;

					p = p + 1;

					}

				else

					{

					aMainDept[sDeptPrev][p] = sPosnPrev;

					sDeptPrev = sDept;

					p = 0;

					};				

				aMainPosn[sPosnPrev] = aTempEmp;

				var aTempEmp = new Array();

				aTempEmp[0] = sEmp;

				q = 0 ;

				sPosnPrev = sPosn;

				};

			};

		aMainDept[sDept][p] = sPosn;

		aMainPosn[sPosn] = aTempEmp;

			

		// Update Position ValueList when Department is changed.

		function selPosition()

			{

			with (document.myform)

			{

			var nIndex = department.selectedIndex ;

			var sIndex = department.value ;

			if (nIndex > 0)

				{

				// Clear the existing Options of Position and Employee

				nPosnLen = position.options.length;

				for (i = nPosnLen; i > 0; i--) { position.options[i] = null ; } ;

				nEmpLen = emp_name.options.length

				for (i = nEmpLen; i > 0; i--) { emp_name.options[i] = null ; } ;

				nDepLen = aMainDept[sIndex].length;

				for (a=0; a < nDepLen; a++)

					{

					position.options[a+1] = new Option(aMainDept[sIndex][a]) ;

					position.options[a+1].value = aMainDept[sIndex][a] ;

					};

				}

			else

				{

				nPosnLen = position.options.length;

				for (i = nPosnLen; i > 0; i--) { position.options[i] = null ; } ;

				nEmpLen = emp_name.options.length;

				for (i = nEmpLen; i > 0; i--) { emp_name.options[i] = null ; } ;

				};

			};

			};

		// Update Employee ValueList when Position is changed.

		function selEmployee()

			{

			with (document.myform)

			{

			var nIndex = position.selectedIndex ;

			var sIndex = position.value ;

			if (nIndex > 0)

				{

				// Clear the existing Options of Employee

				nEmpLen = emp_name.options.length;

				for (i = nEmpLen; i > 0; i--) { emp_name.options[i] = null ; } ;

				nPosnLen = aMainPosn[sIndex].length;

				for (a=0; a < nPosnLen; a++)

					{

					emp_name.options[a+1] = new Option(aMainPosn[sIndex][a]) ;

					emp_name.options[a+1].value = aMainPosn[sIndex][a] ;

					};

				}

			else

				{

				nEmpLen = emp_name.options.length;

				for (i = nEmpLen; i > 0; i--) { emp_name.options[i] = null ; } ;				

				};

			};

			};

	</script>

</head>

<body>Hello World....<br>

<form method="post" action="#" name="myform">

<select name="department" onchange="Javascript:selPosition();">

<option value="">Please Select a Department</option>

		[FMP-ValueList:department]

		<option value="[FMP-ValueListItem]">[FMP-ValueListItem]</option>

		[/FMP-ValueList]

</select><br>

<select name="position" onchange="Javascript:selEmployee();">

<option value="">Please Select a Position</option>

</select><br>

<select name="emp_name">

<option value="">Please Select an Employee</option>

</select></form>

</body>

</html>

All the best.

Garry

Link to comment
Share on other sites

Garry,

OH (dramatic pause) MY (dramatic pause) GAWD (dramatic pause)!

How amazing is that! It worked first time out. You are awesome (just picture me bowing down before you)!

Okay, just two little follow up questions.

First, since these fields will be accessed quite a bit, is it possible to load the arrays into say a fixed frame (like a banner) so that it can be accessed multiple times within a single session (this would cut down on the load wait time and bandwidth.

Second, when I go to the page that the popups are on, can I have some sort of java "alert" that will tell the user that the employee information is loading.

I owe you a big rainbow cake (if I only knew what rainbow cake was). Once again, thanks for all your help. I'm in awe of your amazing technological skill. I look forward to meeting you one day in Vegas.

Talk to you soon,

Jeff

Link to comment
Share on other sites

Yahoo! it worked smile.gif

Yes, you can have the arrays and functions in one Frame and have them accessed by another Frame. I have a similar application for people building quotes. One Frame has the product categories, another Frame has the Products, and the thrid Frame has the quote. Each product has a button which allows it to be added to the quote.

You could use some sort of "pre-page" with "Loading..." as the text. Or, you may be able to use DHTML Layers (or Frames) to do this.

Looking forward to Las Vegas wink.gif

All the best.

Garry

Link to comment
Share on other sites

Garry,

Once again into the fray! See I gave you a whole day off! Okay. I got the arrays to load into my static left frame called "navigation" and the "myform" that I am creating is in a sub frame on the right bottom called "body". I'm just not sure which item points to which to get them to talk to each other. Do I add "top.navigation.Javascript:selPosition();" to the popup lists to get them to see the data in the body frame? or do I add "(top.body.document.myform)" to the navigation frame to send the data to the form? or am I just flailing my arms around in the air like a crazy person trying to look like I know what I'm doing...you decide.

Thanks for any input.

-Jeff

Link to comment
Share on other sites

Garry,

So after wasting a WHOLE night to find out that I had some hellish script that was screwing up my data, I got the "new" entry form to work just fine! And no, I really don't enjoy sleeping that much. Which leads me into my next question...while working on my "edit" form, I found out two things. First, that if I insert the pre-existing data into the popup field, the arrays treat it like a separate piece of data (i.e. if you have already chosen "Rainbow Cake" it appears at the top of the list AND in the list where it normally would be). The bad part is that because it doesn't recognize the existing data, the conditional arrays don't connect. Is there some secret to fixing this? Or am I just up a creek?

Second, when I return multiple records to the same "edit" page, the conditional arrays don't work. And I can't figure out why. I'm assuming it's because they can't all pull the same array name at the same time on the same page. Is this true? Am I asking too much?

Oh fount of great knowledge. Any guidance would be appreciated like water in the desert. (Yeah, that's where I live...in the desert!)

Talk to you soon,

-Jeff

Link to comment
Share on other sites

Jeff,

A number of ways exist to have the "drop-downs" display the value of a record.

Do you have a listing page and the three drop-downs adjacent to each of the listed records? If so, the <selects> will need to have different names, or no names and referenced by number; e.g. document.myform.elements[23] (This number can be passed to the functions as a parameter.)

All the best.

Garry

Link to comment
Share on other sites

This topic is 7880 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.