CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 Jaro's dependent listboxes

Print topic Send  topic

Author Message
kipdole
Posted: 01/10/2003, 3:21 PM

Before I spend most likely many hours I was wondering if this code will work in an edit type of form?

I only see examples where this is being used in a search form. I am making a help desk application where I want the user to first select the company.

From this information I want them to pick from a restricted list of:
-Support contracts the company has purchased
-Employees of the company

Thanks for your help
Headhunter
Posted: 01/11/2003, 10:47 AM

Look here:

http://support.codecharge.com/kb_article.asp?s_keyword=...=&article_id=61

and/or here:

http://headhunter.dnsalias.org:14080/dropdown/hwr_pc_list.php?pc_id=1

To get the project file, mailbart.verstricht@pandora.be
Lars
Posted: 01/12/2003, 6:54 AM

Look here:
http://www.gotocode.com/disc_viewt.asp?mid=17739
feha
Posted: 01/12/2003, 8:12 AM

Great Job Headhunter

regards
feha
[www.vision.to]
banjo
Posted: 01/12/2003, 12:52 PM

Is this the CC2 one you're asking about.
If so, Yes, it works fine in a record form. I've several apps running OK with it in record forms.

Wish it was redone for CCS.

On the Dreamweaver Tech site there's a good article on dependent listboxes.
Search for "creating client-side dynamic dependent list boxes".

banjo

Kip Dole
Posted: 01/13/2003, 3:19 PM

Thanks for everyone's help. I let you know if I am successful. I work on project around an hour per day so it will probably take me a week.

Oh, I am using CC2.


Kip Dole
Posted: 01/16/2003, 2:20 PM

Yes I could get Jaro's dependent list boxes to display as in the example.

However I was not able to:
Save the value that I selected in the list box.
Display a value other than the default in the list box.

If anyone has an suggestions please post them here.

Thanks a million!



kipdole
Posted: 01/17/2003, 1:42 PM

Here is the code I have so far. What I am trying to do is have these dependent list boxes works within a record page. I want the list box to display the previous name selected if the record is an edit and to insert the info if the record is new.

Thanks in advance!

//Code Under the Open Event of the page
SetVar "level2_2" , """" & "All" & "#" & "0" & """"
Parse "level2_2s",true
SetVar "level1" , "All#0"
Parse "level1s",true
SetVar "level2_2s",""

set rs = cn.execute("select [client_id], [company_name] from [dbo_client] order by company_name desc")
set subrs2 = Server.CreateObject("ADODB.Recordset")
while not rs.eof
' level2
set subrs2 = cn.execute ("select [email_address_id],[email]+' '+[phone] from [dbo_email_address] where company_id=" & rs(0) & " order by email")
i=0
while not subrs2.eof
name2 = subrs2(1)
id2 = subrs2(0)
subrs2.MoveNext
if subrs2.eof then
SetVar "level2_2" , """" & name2 & "#" & id2 & ""","
Parse "level2_2s",true
SetVar "level2_2" , """" & "All" & "#" & "0" & """"
else
SetVar "level2_2" , """" & name2 & "#" & id2 & ""","
end if
Parse "level2_2s",true
i = i + 1
wend
subrs2.close
if i = 0 then
SetVar "level2_2" , """" & "All" & "#" & "0" & """"
Parse "level2_2s",true
end if
SetVar "level1" , rs(1) & "#" & rs(0)
Parse "level1s",true
SetVar "level2_2s",""
rs.MoveNext
wend
rs.close
set subrs2 = nothing

//Code Under the Header footer of the record page
<script language="Javascript">
// Description : Level1(All,Value1,Value2, ...)
// Level2(All,Value11OfValue1,Value12OfValue1,Value21OfValue2, ...
// Setting selected values for level1, level2, level3 after refresh web site

var level1s = new Array();
<!--Beginlevel1s-->
level1s["{level1}"] = new Array(
<!--Beginlevel2_2s-->
{level2_2}
<!--Endlevel2_2s-->
);
<!--Endlevel1s-->

// Defintion vars and objects
var objforms = document.forms["edit_call_log1"];
var objlevs1 = objforms.client_id;
var objform = document.edit_call_log1;
var objlev1 = document.edit_call_log1.client_id;
var objlev2 = document.edit_call_log1.email_address_id;
var objchange2 = document.all["client_id"];
var cFieldNameLevel1 = "client_id";
var cFieldNameLevel2 = "email_address_id";
var nSelectedIndexLevel2 = 0;
var k=0;
for (i in level1s)
{
level1_name_id = i.toString().split("#");
objlevs1.options[k] = new Option ( level1_name_id[0] , level1_name_id[1])
k=k+1;
}

function fill_level2() {
var lbopt = objlev1.options;
var arr = level1s[lbopt[lbopt.selectedIndex].text];
key = lbopt[lbopt.selectedIndex].text + "#" + lbopt[lbopt.selectedIndex].value;
for (i=objlev2.options.length; i >=0 ; i--)
{
objlev2.options=null;
}
for (i=0; i < level1s[key].length; i++)
{
level2_name_id = level1s[key].split("#");
objlev2.options = new Option(level2_name_id[0],level2_name_id[1])
if (objlev2.options.value==nSelectedIndexLevel2)
{
// The select field value
objlev2.options.selected=true;
}
}
}

objchange2.onchange = fill_level2;


function parseQueryString (str)
{
str = str ? str : location.search;
var query = str.charAt(0) == '?' ? str.substring(1) : str;
var args = new Object();
if (query)
{
var fields = query.split('&');
for (var f = 0; f < fields.length; f++) {
var field = fields[f].split('=');
// If URL has value for Level1 or Level2
// My condition for creation args for dependent combobox, only
if (field[0]==cFieldNameLevel1 || field[0]==cFieldNameLevel2)
{
if (field[1]>0)
{
args[unescape(field[0].replace(/\+/g, ' '))]=unescape(field[1].replace(/\+/g, ' '));
if (field[0]==cFieldNameLevel2)
{
// The number of selected index for fieldlevel2
nSelectedIndexLevel2 = field[1];
}
}
}
}
}
return args;
}

var args = parseQueryString ();

for (var arg in args)
{
var opt = objform.elements[arg].options;
for (i=0; i < opt.length; i++)
{
if (opt.value == args[arg])
{
opt.selected = true;
break;
}
}
}

fill_level2();

</script>


   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.