fkhashouf
|
| Posted: 06/10/2003, 1:32 AM |
|
Dear all,
I have the below questions I hope someone can help me.
q1 : How can you create a dynamic list box that gets affected by a previous selection of another list box ? example listbox1(you choose) Intel, Listbox2 shows processor speeds of intel only. If you choose in listbox1 AMD, you get to see in listbox2 AMD processor speeds. This is all stored in a table with two columns brand and speed.
q2 : how can I make the search result appearing in the gird to point to a relative web page.
q3 : how can I run the samples on the codecharge website, after you download it. I tried to open with codecharge studio but I cannot find a ccs file ?
q4 : how do you get the CCS Example Pack to work, it does not work with me?
Regards
|
|
|
 |
Vito
|
| Posted: 06/10/2003, 4:05 AM |
|
a1: Open HTML and add for first select box onChange event
<select name="brand" onChange="document.form_name.action='page_name.php';
document.form_name.submit()">
For second select box you must add where condition in datasource properties
based on this brand value.
a2: CCS by default allways used relative links to pages or did you mean something else?
|
|
|
 |
Sam Powell
|
| Posted: 06/10/2003, 1:48 PM |
|
In answer to your first question - how to change the values on listbox2 based on what was selected on listbox1 - I was able to accomplish this by creating a Javascript function which changed the values of the select list based on a previous selection. In my case I wanted to have a different list of State/Province codes based on the Country Code selected. Ie. If user selected US then list all US State codes - If user selected CA (Canada) then list all Canadian Province Codes and so on.
1) Perform an OnChange event on the Country Code Field (ListBox1) (The first for i loop) cleans the Select Object in case the country selected has less values than the previous one.
//page_parties_Country_OnChange @13-D21015DC
function page_parties_Country_OnChange()
{
var result;
//End page_parties_Country_OnChange
// -------------------------
var theForm = document.forms["parties"];
var CurrentSelectedValue = 0;
var sState = theForm.State.value;
var SizeOf = theForm.State.options.length;
for (var i = 0 ; i < SizeOf ; i ++) {
if (sState == theForm.State.options) {
CurrentSelectedValue=0;
}
theForm.State.options = null;
}
theForm.State.length = 0;
LoadStateCodes();
theForm.State.options[CurrentSelectedValue].selected=true;
//Custom Code @36-2A29BDB7
// -------------------------
//End Custom Code
//Close page_parties_Country_OnChange @13-BC33A33A
return result;
}
2) Create your Load States Codes Function (Load listbox2) In my case this is what I had.
function LoadStateCodes() {
var theForm = document.forms["parties"];
var sCountry = theForm.Country.value;
if (sCountry == "AR") {
var StateValue = new Option("Tucuman", "TU");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Salta", "SA");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Cordoba", "CB");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Buenos Aires", "BU");
theForm.State.options.add(StateValue,0);
return;
}
if (sCountry == "BR") {
var StateValue = new Option("TOCANTINS", "TO");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("SERGIPE", "SE");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("SAO PAULO", "SP");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("SANTA CATARINA", "SC");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("RORAIMA", "RR");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("RONDONIA", "RO");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("RIO GRANDE DO SUL", "RS");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("RIO GRANDE DO NORTE", "RN");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("RIO DE JANEIRO", "RJ");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("PIAUI", "PI");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("PERNAMBUCO", "PE");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("PARANA", "PR");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("PARAIBA", "PB");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("PARA", "PA");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("MINAS GERAIS", "MG");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("MATO GROSSO DO SUL", "MS");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("MATO GROSSO", "MT");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("MARANHAO", "MA");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("GOIAS", "GO");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("ESPIRITO SANTO", "ES");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("DISTRITO FEDERAL", "DF");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("CEARA", "CE");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("BAHIA", "BA");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("AMAZONAS", "AM");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("AMAPA", "AP");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("ALAGOAS", "AL");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Acre", "AC");
theForm.State.options.add(StateValue,0);
return;
}
if (sCountry == "CA") {
var StateValue = new Option("Yukon Territory", "YT");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Saskatchewan", "SK");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Quebec", "PQ");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Prince Edward Island", "PE");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Ontario", "ON");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Nova Scotia", "NS");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Northern Territories", "NT");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Newfoundland", "NF");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("New Brunswick", "NB");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Manitoba", "MB");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("British Columbia", "BC");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Alberta", "AB");
theForm.State.options.add(StateValue,0);
return;
}
if (sCountry == "MX") {
var StateValue = new Option("ZACATECAS", "ZA");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("YUCATAN", "YU");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("VERACRUZ", "VE");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("TLAXCALA", "TL");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("TAMAULIPAS", "TM");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("TABASCO", "TB");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("SONORA", "SO");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("SINALOA", "SI");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("SAN LUIS POTOSI", "SL");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("QUINTANA ROO", "QR");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("QUERETARO", "QT");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("PUEBLA", "PU");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("OAXACA", "OA");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("NUEVO LEON", "NL");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("NAYARIT", "NA");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("MORELOS", "MO");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("MICHOACAN", "MI");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("MEXICO", "MX");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("JALISCO", "JA");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("HIDALGO", "HG");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("GUERRERO", "GR");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("GUANAJUANTO", "GT");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("DURANGO", "DG");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("DISTRITO", "DF");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("COLIMA", "CL");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("COAHUILA", "CO");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("CHIHYAHYA", "CH");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("CHIAPAS", "CS");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("CAMPECHE", "CM");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("BAJA CALIFORNIA SUR", "BS");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Baja California", "BC");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Aguascalientes", "AG");
theForm.State.options.add(StateValue,0);
return;
}
if (sCountry == "US") {
var StateValue = new Option("Wyoming", "WY");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Wisconsin", "WI");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("West Virginia", "WV");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Washington", "WA");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Virginia", "VA");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Virgin Islands", "VI");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Vermont", "VT");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Utah", "UT");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Texas", "TX");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Tennessee", "TN");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("South Dakota", "SD");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("South Carolina", "SC");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Rhode Island", "RI");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Puerto Rico", "PR");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Pennsylvania", "PA");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Oregon", "OR");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Oklahoma", "OK");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Ohio", "OH");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("North Dakota", "ND");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("North Carolina", "NC");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("New York", "NY");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("New Mexico", "NM");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("New Jersey", "NJ");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("New Hampshire", "NH");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Nevada", "NV");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Nebraska", "NE");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Montana", "MT");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Missouri", "MO");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Mississippi", "MS");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Minnesota", "MN");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Michigan", "MI");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Mexico", "MX");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Massach", "MA");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Maryland", "MD");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Maine", "ME");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Louisiana", "LA");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Kentucky", "KY");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Kansas", "KS");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Iowa", "IA");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Indiana", "IN");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Illinois", "IL");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Idaho", "ID");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Hawaii", "HI");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Georgia", "GA");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Florida", "FL");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("District of Columbia", "DC");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Delaware", "DE");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Connecticut", "CT");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Colorado", "CO");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("California", "CA");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Arkansas", "AR");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Arizona", "AZ");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Alaska", "AK");
theForm.State.options.add(StateValue,0);
var StateValue = new Option("Alabama", "AL");
theForm.State.options.add(StateValue,0);
}
}
</script>
Note the LoadStateCodes() function was automatically created using the Server Side BeforeShow event and inserted into HTML code by means of the $Tpl->SetVar() function in PHP. I inserted the following code into the HTML form right before the <BODY> tag.
<script>
function LoadStateCodes() {
<!-- BEGIN StateValues -->{StateValueCode}
<!-- END StateValues -->
}
</script>
Then the following PHP code in the BeforeShow event to create the JavaScript code.
function Page_BeforeShow()
{
$Page_BeforeShow = true;
//End Page_BeforeShow
//Custom Code @38-2A29BDB7
// -------------------------
global $Tpl;
$db = new clsDBEZtrack;
$Tpl->SetVar("StateValueCode",'var theForm = document.forms["parties"];');
$Tpl->parse("StateValues",true);
$Tpl->SetVar("StateValueCode",'var sCountry = theForm.Country.value; ');
$Tpl->parse("StateValues",true);
$Tpl->SetVar("StateValueCode"," ");
$Tpl->parse("StateValues",true);
// Ok now Build script Loading Section
$sSQLState = "SELECT Code,Description,Country FROM states ORDER By Country, Description Desc";
$db->query($sSQLState);
$PriorCountry = "";
$StateCount=0;
while ($db->next_record())
{
$Code = $db->f("Code");
$Description = $db->f("Description");
$Country = $db->f("Country");
if ($Country != $PriorCountry) {
if ($PriorCountry > "") {
$Tpl->SetVar("StateValueCode"," return;");
$Tpl->parse("StateValues",true);
$Tpl->SetVar("StateValueCode","}");
$Tpl->parse("StateValues",true);
$Tpl->SetVar("StateValueCode"," ");
$Tpl->parse("StateValues",true);
}
$Tpl->SetVar("StateValueCode",'if (sCountry == "' . $Country . '") {') ;
$Tpl->parse("StateValues",true);
$StateCount=0;
}
$Tpl->SetVar("StateValueCode",' var StateValue = new Option("' . $Description . '", "' . $Code . '");') ;
$Tpl->parse("StateValues",true);
$Tpl->SetVar("StateValueCode",' theForm.State.options.add(StateValue,0);');
$Tpl->parse("StateValues",true);
$PriorCountry = $Country;
$StateCount ++;
}
if ($StateCount) {
$Tpl->SetVar("StateValueCode","}");
$Tpl->parse("StateValues",true);
}
// -------------------------
//End Custom Code
//Close Page_BeforeShow @1-4BC230CD
return $Page_BeforeShow;
}
//End Close Page_BeforeShow
Hope the above helps!!!
|
|
|
 |
fkhashouf
|
| Posted: 06/12/2003, 12:08 AM |
|
Thanks to all for your help.
|
|
|
 |
|