• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1760
  • Last Modified:

populate states list box based on country selected

I need help in populating states list box when a country is selected. I am getting all the countries from the databse and the country list box works fine. But what I need is that if a particular country is selected the appropriate states are also shown.

here's my code where I link country to states

<SCRIPT>
      var states = new DynamicOptionList();
      var home_states     = new DynamicOptionList();

      states.addDependentFields("business_address_country","state");

      states.forValue("AUS").addOptionsTextValue("ACT","ACT","NSW","NSW","NT","NT","QLD","QLD","SA","SA","TAS","TAS","VIC","VIC","WA","WA");
      states.forValue("CAN").addOptionsTextValue("Alberta","AB","British Columbia","BC","Manitoba","MB","New Brunswick","NB","Newfoundland","NF","Nova Scotia","NS","Northwest Territories","NT","Nunavut","NU","Ontario","ON","Prince Edward Island","PI","Quebec","PQ","Saskatchewan","SK","Yukon","YT");
      states.forValue("MEX").addOptionsTextValue("AG","AG","DF","DF","NL","NL");
      states.forValue("USA").addOptionsTextValue("Alabama","AL","Alaska","AK","Arizona","AZ","Arkansas","AR","California","CA","Colorado","CO","Connecticut","CT","District of Columbia","DC","Delaware","DE","Florida","FL","Georgia","GA","Hawaii","HI","Idaho","ID","Illinois","IL","Indiana","IN","Iowa","IA","Kansas","KS","Kentucky","KY","Louisiana","LA","Maine","ME","Maryland","MD","Massachusetts","MA","Michigan","MI","Minnesota","MN","Mississippi","MS","Missouri","MO","Montana","MT","Nebraska","NE","Nevada","NV","New Hampshire","NH","New Jersey","NJ","New Mexico","NM","New York","NY","North Carolina","NC","North Dakota","ND","Ohio","OH","Oklahoma","OK","Oregon","OR","Pennsylvania","PA","Puerto Rico","PR","Rhode Island","RI","South Carolina","SC","South Dakota","SD","Tennessee","TN","Texas","TX","Utah","UT","Vermont","VT","Virginia","VA","Washington","WA","West Virginia","WV","Wisconsin","WI","Wyoming","WY");

      states.selectFirstOption = true;
</SCRIPT>


Here is the code where I create the list box and populate them


       <tr>
            <td>State/Province: <font color="red">*</font></td>
            <td><select name="state"><script>states.printOptions("state")</script></select></td>
      </tr>
      <tr>
            <td>Country: <font color="red">*</font></td>
            <td>
                  <select name="business_address_country" class="textfield">
                        <option value="0">* Select One *</option>
<%
                        for(int key_index = 0; key_index < country_keys.length; key_index++) {
                              String next_key   = (String)country_keys[key_index];
                              String next_value = (String)countries.get(next_key);
%>
                              <option value="<%= next_key %>"><%= next_value %></option>
<%                        } %>
                  </select>
            </td>
0
royalcyber
Asked:
royalcyber
  • 18
  • 12
1 Solution
 
ZylochCommented:
What is a DynamicOptionList?

Is it an object in a package? If it is, can you show its code?
0
 
ZvonkoSystems architectCommented:
I do not see this line in your snippets:

<select name="state"><script type="text/javascript">names.printOptions("state");</script></select>

0
 
ZvonkoSystems architectCommented:
Sorry, it should be this:

<select name="state"><script type="text/javascript">states.printOptions("state");</script></select>

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ZvonkoSystems architectCommented:
All together it looks like this:


       <tr>
          <td>State/Province: <font color="red">*</font></td>
          <td><select name="state"><script>states.printOptions("state")</script></select></td>
     </tr>
     <tr>
          <td>Country: <font color="red">*</font></td>
          <td>
               <select name="business_address_country" class="textfield">
                    <option value="0">* Select One *</option>
<%
                    for(int key_index = 0; key_index < country_keys.length; key_index++) {
                         String next_key   = (String)country_keys[key_index];
                         String next_value = (String)countries.get(next_key);
%>
                         <option value="<%= next_key %>"><%= next_value %></option>
<%                    } %>
               </select>
          </td>

<SCRIPT>
     var states = new DynamicOptionList();
     //var home_states     = new DynamicOptionList();

     states.addDependentFields("business_address_country","state");

     states.forValue("AUS").addOptionsTextValue("ACT","ACT","NSW","NSW","NT","NT","QLD","QLD","SA","SA","TAS","TAS","VIC","VIC","WA","WA");
     states.forValue("CAN").addOptionsTextValue("Alberta","AB","British Columbia","BC","Manitoba","MB","New Brunswick","NB","Newfoundland","NF","Nova Scotia","NS","Northwest Territories","NT","Nunavut","NU","Ontario","ON","Prince Edward Island","PI","Quebec","PQ","Saskatchewan","SK","Yukon","YT");
     states.forValue("MEX").addOptionsTextValue("AG","AG","DF","DF","NL","NL");
     states.forValue("USA").addOptionsTextValue("Alabama","AL","Alaska","AK","Arizona","AZ","Arkansas","AR","California","CA","Colorado","CO","Connecticut","CT","District of Columbia","DC","Delaware","DE","Florida","FL","Georgia","GA","Hawaii","HI","Idaho","ID","Illinois","IL","Indiana","IN","Iowa","IA","Kansas","KS","Kentucky","KY","Louisiana","LA","Maine","ME","Maryland","MD","Massachusetts","MA","Michigan","MI","Minnesota","MN","Mississippi","MS","Missouri","MO","Montana","MT","Nebraska","NE","Nevada","NV","New Hampshire","NH","New Jersey","NJ","New Mexico","NM","New York","NY","North Carolina","NC","North Dakota","ND","Ohio","OH","Oklahoma","OK","Oregon","OR","Pennsylvania","PA","Puerto Rico","PR","Rhode Island","RI","South Carolina","SC","South Dakota","SD","Tennessee","TN","Texas","TX","Utah","UT","Vermont","VT","Virginia","VA","Washington","WA","West Virginia","WV","Wisconsin","WI","Wyoming","WY");

     states.selectFirstOption = true;
</SCRIPT>


<td>
<select name="state"><script type="text/javascript">states.printOptions("state");</script></select>
</td>



0
 
ZvonkoSystems architectCommented:
Stop! Now I see your line.

0
 
ZvonkoSystems architectCommented:
Now, where is the upper JavaScript included? In the page <HEAD>? Or after the <SELECT>s?

0
 
ZvonkoSystems architectCommented:
Do you have this <body> handler:

<BODY onload="initDynamicOptionLists();">


0
 
royalcyberAuthor Commented:
Here is my header file

I added the onload="initDynamicOptionLists();" as a body attribute, but it still doesn' work


<%@ page import="java.util.*" %>
<%@ page import="java.text.*" %>
<%@ page import="com.ccim.Globals" %>
<%@ page import="com.ccim.data.*" %>
<%
      Format date_formatter = new SimpleDateFormat("EEEE, MMMMM dd, yyyy");
      String today          = date_formatter.format(new Date());
      String message        = (String)request.getAttribute("MESSAGE") == null ? "" : (String)request.getAttribute("MESSAGE");
      String website_host   = (String)request.getAttribute("WEBSITE_HOST");
      String admin_user_id  = (String)request.getAttribute("ADMIN_USER_ID");
%>

<!-- Javascript Include Files > IMPORTANT -->
            <script language="JavaScript" src="/common/javascripts/validations.js" type="text/javascript"></script>
            <script language="JavaScript" src="/common/javascripts/include_dropdown.js" type="text/javascript"></script>
            <script language="JavaScript" src="/common/javascripts/include_bottom.js" type="text/javascript"></script>
            <script language="JavaScript" src="/common/javascripts/include_pagepieces.js" type="text/javascript"></script>
            <script language="JavaScript" src="/common/javascripts/header_random.js" type="text/javascript"></script>
            <script language="JavaScript" src="/common/javascripts/limit_characters.js" type="text/javascript"></script>
            <script language="JavaScript" src="/common/javascripts/popup.js" type="text/javascript"></script>
            <script language="JavaScript" src="/common/javascripts/transactions.js" type="text/javascript"></script>
            <script language="JavaScript" src="/common/javascripts/profiler2.js" type="text/javascript"></script>
            <script language="JavaScript" src="/common/javascripts/profiler2-dynamiclist.js" type="text/javascript"></script>
            <script language="JavaScript" src="/common/javascripts/ccim_net_forwarding.js" type="text/javascript"></script>
<html>
      <head>
            <title>CCIM Chapters</title>
            <link href="/common/style/admin.css" rel="stylesheet" type="text/css">
      </head>
      <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="initDynamicOptionLists();">
            <table width="793" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                        <td bgcolor="#FFFFFF" height="75">&nbsp;&nbsp;CHAPTER NAME/LOGO GOES HERE &nbsp;&nbsp;(<%= website_host %>)(<%= admin_user_id %>)</td>
                  </tr>
            </table>
            <table width="793" height="29" background="/images/menu.gif" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                        <td nowrap align="right"><b><%= today %>&nbsp;&nbsp;&nbsp;&nbsp;</b></td>
                  </tr>
            </table>
0
 
ZvonkoSystems architectCommented:
Is your page accessible on the internet?
0
 
royalcyberAuthor Commented:
no
0
 
ZvonkoSystems architectCommented:
can you post ONLY the plain HTML source as seen in browser?
0
 
royalcyberAuthor Commented:
Would you know if I need to put any other .js file. Right now the application is hosted on my local computer and when I run the application I get all the country names from the database
but when I select a country name the state option does not change. Please let me know if you need any other information
0
 
royalcyberAuthor Commented:






<!-- Javascript Include Files > IMPORTANT -->
            <script language="JavaScript" src="/common/javascripts/validations.js" type="text/javascript"></script>
            <script language="JavaScript" src="/common/javascripts/include_dropdown.js" type="text/javascript"></script>
            <script language="JavaScript" src="/common/javascripts/include_bottom.js" type="text/javascript"></script>
            <script language="JavaScript" src="/common/javascripts/include_pagepieces.js" type="text/javascript"></script>
            <script language="JavaScript" src="/common/javascripts/header_random.js" type="text/javascript"></script>
            <script language="JavaScript" src="/common/javascripts/limit_characters.js" type="text/javascript"></script>
            <script language="JavaScript" src="/common/javascripts/popup.js" type="text/javascript"></script>
            <script language="JavaScript" src="/common/javascripts/transactions.js" type="text/javascript"></script>
            <script language="JavaScript" src="/common/javascripts/profiler2.js" type="text/javascript"></script>
            <script language="JavaScript" src="/common/javascripts/profiler2-dynamiclist.js" type="text/javascript"></script>
            <script language="JavaScript" src="/common/javascripts/ccim_net_forwarding.js" type="text/javascript"></script>
<html>
      <head>
            <title>CCIM Chapters</title>
            <link href="/common/style/admin.css" rel="stylesheet" type="text/css">
      </head>
      <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="initDynamicOptionLists();">
            <table width="793" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                        <td bgcolor="#FFFFFF" height="75">&nbsp;&nbsp;CHAPTER NAME/LOGO GOES HERE &nbsp;&nbsp;(localhost)(12345678)</td>
                  </tr>
            </table>
            <table width="793" height="29" background="/images/menu.gif" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                        <td nowrap align="right"><b>Wednesday, March 29, 2006&nbsp;&nbsp;&nbsp;&nbsp;</b></td>
                  </tr>
            </table>


  <display:table name="test" export ="false">
  <display:column title="address_1" property="address_1"/>
  <display:column title="address_2" property="address_2"/>
  </display:table>



241
<Script>

      var states = new DynamicOptionList();

      states.addDependentFields("country","state");

      states.forValue("AUS").addOptionsTextValue("ACT","ACT","NSW","NSW","NT","NT","QLD","QLD","SA","SA","TAS","TAS","VIC","VIC","WA","WA");
      states.forValue("CAN").addOptionsTextValue("Alberta","AB","British Columbia","BC","Manitoba","MB","New Brunswick","NB","Newfoundland","NF","Nova Scotia","NS","Northwest Territories","NT","Nunavut","NU","Ontario","ON","Prince Edward Island","PI","Quebec","PQ","Saskatchewan","SK","Yukon","YT");
      states.forValue("MEX").addOptionsTextValue("AG","AG","DF","DF","NL","NL");
      states.forValue("USA").addOptionsTextValue("Alabama","AL","Alaska","AK","Arizona","AZ","Arkansas","AR","California","CA","Colorado","CO","Connecticut","CT","District of Columbia","DC","Delaware","DE","Florida","FL","Georgia","GA","Hawaii","HI","Idaho","ID","Illinois","IL","Indiana","IN","Iowa","IA","Kansas","KS","Kentucky","KY","Louisiana","LA","Maine","ME","Maryland","MD","Massachusetts","MA","Michigan","MI","Minnesota","MN","Mississippi","MS","Missouri","MO","Montana","MT","Nebraska","NE","Nevada","NV","New Hampshire","NH","New Jersey","NJ","New Mexico","NM","New York","NY","North Carolina","NC","North Dakota","ND","Ohio","OH","Oklahoma","OK","Oregon","OR","Pennsylvania","PA","Puerto Rico","PR","Rhode Island","RI","South Carolina","SC","South Dakota","SD","Tennessee","TN","Texas","TX","Utah","UT","Vermont","VT","Virginia","VA","Washington","WA","West Virginia","WV","Wisconsin","WI","Wyoming","WY");

      states.selectFirstOption = true;
</Script>
<br>
<h1>Events</h1>


<form  action="chapter_admin?action=add_events" method="post">
<table border="0">
      <tr>
            <td>Event Date:</td>
            <td><input type="text" class="textfield" size="30" name="EVENT_DATE" value="null"</td>
      </tr>
      <tr>
            <td>ADDRESS 1:</td>
            <td><input type="text" class="textfield" size="30" name= "ADDRESS1" value="null" maxlength="80"></td>
      </tr>
      <tr>
            <td>ADDRESS 2:</td>
            <td><input type="text" class="textfield" size="30" name= "ADDRESS2" value="null" maxlength="80"></td>
      </tr>
      <tr>
            <td>ADDRESS 3:</td>
            <td><input type="text" class="textfield" size="30" name= "ADDRESS3" value="null" maxlength="80"></td>
      </tr>
      <tr>
            <td>CITY:</td>
            <td><input type="text" class="textfield" size="30" name= "CITY" value="null" maxlength="80"></td>
       
            <td>State/Province: <font color="red">*</font></td>
            <td><select name="state"><script>states.printOptions("state")</script></select></td>
      </tr>
      <tr>
            <td>ZIP:</td>
            <td><input type="text" class="textfield" size="30" name= "ZIP" value="null" maxlength="80"></td>
      
            <td>Country: <font color="red">*</font></td>
            <td>
                  <select name="country" class="textfield">
                        <option value="0">* Select One *</option>

                              <option value="AFG" selected>Afghanistan</option>

                              <option value="ALB" selected>Albania</option>

                              <option value="DZA" selected>Algeria</option>

                              <option value="ASM" selected>American Samoa</option>

                              <option value="AND" selected>Andorra</option>

                              <option value="AGO" selected>Angola</option>

                              <option value="AIA" selected>Anguilla</option>

                              <option value="ATA" selected>Antarctica</option>

                              <option value="ATG" selected>Antigua And Barbuda</option>

                              <option value="ARG" selected>Argentina</option>

                              <option value="ARM" selected>Armenia</option>

                              <option value="ABW" selected>Aruba</option>

                              <option value="AUS" selected>Australia</option>

                              <option value="AUT" selected>Austria</option>

                              <option value="AZE" selected>Azerbaijan</option>

                              <option value="BHS" selected>Bahamas</option>

                              <option value="BHR" selected>Bahrain</option>

                              <option value="BGD" selected>Bangladesh</option>

                              <option value="BRB" selected>Barbados</option>

                              <option value="BLR" selected>Belarus</option>

                              <option value="BEL" selected>Belgium</option>

                              <option value="BLZ" selected>Belize</option>

                              <option value="BEN" selected>Benin</option>

                              <option value="BMU" selected>Bermuda</option>

                              <option value="BTN" selected>Bhutan</option>

                              <option value="BOL" selected>Bolivia</option>

                              <option value="BIH" selected>Bosnia And Herzegowina</option>

                              <option value="BWA" selected>Botswana</option>

                              <option value="BVT" selected>Bouvet Island</option>

                              <option value="BRA" selected>Brazil</option>

                              <option value="IOT" selected>British Indian Ocean Terr</option>

                              <option value="BRN" selected>Brunei Darussalam</option>

                              <option value="BGR" selected>Bulgaria</option>

                              <option value="BFA" selected>Burkina Faso</option>

                              <option value="BDI" selected>Burundi</option>

                              <option value="KHM" selected>Cambodia</option>

                              <option value="CMR" selected>Cameroon</option>

                              <option value="CAN" selected>Canada</option>

                              <option value="CPV" selected>Cape Verde</option>

                              <option value="CYM" selected>Cayman Islands</option>

                              <option value="CAF" selected>Central African Republic</option>

                              <option value="TCD" selected>Chad</option>

                              <option value="CHL" selected>Chile</option>

                              <option value="CHN" selected>China</option>

                              <option value="CXR" selected>Christmas Island</option>

                              <option value="CCK" selected>Cocos (Keeling) Islands</option>

                              <option value="COL" selected>Colombia</option>

                              <option value="COM" selected>Comoros</option>

                              <option value="COG" selected>Congo</option>

                              <option value="COD" selected>Congo-Democratic Republic</option>

                              <option value="COK" selected>Cook Islands</option>

                              <option value="CRI" selected>Costa Rica</option>

                              <option value="CIV" selected>Cote DIvoire</option>

                              <option value="HRV" selected>Croatia (Hrvatska)</option>

                              <option value="CUB" selected>Cuba</option>

                              <option value="CYP" selected>Cyprus</option>

                              <option value="CZE" selected>Czech Republic</option>

                              <option value="DNK" selected>Denmark</option>

                              <option value="DJI" selected>Djibouti</option>

                              <option value="DMA" selected>Dominica</option>

                              <option value="DOM" selected>Dominican Republic</option>

                              <option value="TMP" selected>East Timor</option>

                              <option value="ECU" selected>Ecuador</option>

                              <option value="EGY" selected>Egypt</option>

                              <option value="SLV" selected>El Salvador</option>

                              <option value="GNQ" selected>Equatorial Guinea</option>

                              <option value="ERI" selected>Eritrea</option>

                              <option value="EST" selected>Estonia</option>

                              <option value="ETH" selected>Ethiopia</option>

                              <option value="EUR" selected>European Community</option>

                              <option value="FLK" selected>Falkland Islands</option>

                              <option value="FRO" selected>Faroe Islands</option>

                              <option value="FJI" selected>Fiji</option>

                              <option value="FIN" selected>Finland</option>

                              <option value="FRA" selected>France</option>

                              <option value="FXX" selected>France - Metropolitan</option>

                              <option value="GUF" selected>French Guiana</option>

                              <option value="PYF" selected>French Polynesia</option>

                              <option value="ATF" selected>French Southern Terr</option>

                              <option value="GAB" selected>Gabon</option>

                              <option value="GMB" selected>Gambia</option>

                              <option value="GEO" selected>Georgia</option>

                              <option value="DEU" selected>Germany</option>

                              <option value="GHA" selected>Ghana</option>

                              <option value="GIB" selected>Gibraltar</option>

                              <option value="GRC" selected>Greece</option>

                              <option value="GRL" selected>Greenland</option>

                              <option value="GRD" selected>Grenada</option>

                              <option value="GLP" selected>Guadeloupe</option>

                              <option value="GUM" selected>Guam</option>

                              <option value="GTM" selected>Guatemala</option>

                              <option value="GIN" selected>Guinea</option>

                              <option value="GNB" selected>Guinea-Bissau</option>

                              <option value="GUY" selected>Guyana</option>

                              <option value="HTI" selected>Haiti</option>

                              <option value="HMD" selected>Heard & Mcdonald Islands</option>

                              <option value="VAT" selected>Holy See (Vatican City )</option>

                              <option value="HND" selected>Honduras</option>

                              <option value="HKG" selected>Hong Kong</option>

                              <option value="HUN" selected>Hungary</option>

                              <option value="ISL" selected>Iceland</option>

                              <option value="IND" selected>India</option>

                              <option value="IDN" selected>Indonesia</option>

                              <option value="IRN" selected>Iran(Islamic Republic Of)</option>

                              <option value="IRQ" selected>Iraq</option>

                              <option value="IRL" selected>Ireland</option>

                              <option value="ISR" selected>Israel</option>

                              <option value="ITA" selected>Italy</option>

                              <option value="JAM" selected>Jamaica</option>

                              <option value="JPN" selected>Japan</option>

                              <option value="JOR" selected>Jordan</option>

                              <option value="KAZ" selected>Kazakhstan</option>

                              <option value="KEN" selected>Kenya</option>

                              <option value="KIR" selected>Kiribati</option>

                              <option value="KOR" selected>Korea, Republic of</option>

                              <option value="PRK" selected>Korea-Demo PeopleS Rep</option>

                              <option value="KWT" selected>Kuwait</option>

                              <option value="KGZ" selected>Kyrgyzstan</option>

                              <option value="LAO" selected>Lao People Demo Republic</option>

                              <option value="LVA" selected>Latvia</option>

                              <option value="LBN" selected>Lebanon</option>

                              <option value="LSO" selected>Lesotho</option>

                              <option value="LBR" selected>Liberia</option>

                              <option value="LBY" selected>Libyan Arab Jamahiriya</option>

                              <option value="LIE" selected>Liechtenstein</option>

                              <option value="LTU" selected>Lithuania</option>

                              <option value="LUX" selected>Luxembourg</option>

                              <option value="MAC" selected>Macau</option>

                              <option value="MKD" selected>Macedonia (Yugoslav Rep)</option>

                              <option value="MDG" selected>Madagascar</option>

                              <option value="MWI" selected>Malawi</option>

                              <option value="MYS" selected>Malaysia</option>

                              <option value="MDV" selected>Maldives</option>

                              <option value="MLI" selected>Mali</option>

                              <option value="MLT" selected>Malta</option>

                              <option value="MHL" selected>Marshall Islands</option>

                              <option value="MTQ" selected>Martinique</option>

                              <option value="MRT" selected>Mauritania</option>

                              <option value="MUS" selected>Mauritius</option>

                              <option value="MYT" selected>Mayotte</option>

                              <option value="MEX" selected>Mexico</option>

                              <option value="FSM" selected>Micronesia-Federated Stat</option>

                              <option value="MDA" selected>Moldova - Republic Of</option>

                              <option value="MCO" selected>Monaco</option>

                              <option value="MNG" selected>Mongolia</option>

                              <option value="MSR" selected>Montserrat</option>

                              <option value="MAR" selected>Morocco</option>

                              <option value="MOZ" selected>Mozambique</option>

                              <option value="MMR" selected>Myanmar</option>

                              <option value="NAM" selected>Namibia</option>

                              <option value="NRU" selected>Nauru</option>

                              <option value="NPL" selected>Nepal</option>

                              <option value="ANT" selected>Netherlands Antilles</option>

                              <option value="NCL" selected>New Caledonia</option>

                              <option value="NZL" selected>New Zealand</option>

                              <option value="NIC" selected>Nicaragua</option>

                              <option value="NER" selected>Niger</option>

                              <option value="NGA" selected>Nigeria</option>

                              <option value="NIU" selected>Niue</option>

                              <option value="NFK" selected>Norfolk Island</option>

                              <option value="MNP" selected>Northern Mariana Islands</option>

                              <option value="NOR" selected>Norway</option>

                              <option value="OMN" selected>Oman</option>

                              <option value="PAK" selected>Pakistan</option>

                              <option value="PLW" selected>Palau</option>

                              <option value="PAN" selected>Panama</option>

                              <option value="PNG" selected>Papua New Guinea</option>

                              <option value="PRY" selected>Paraguay</option>

                              <option value="PER" selected>Peru</option>

                              <option value="PHI" selected>Philippines</option>

                              <option value="PHL" selected>Philippines</option>

                              <option value="PCN" selected>Pitcairn</option>

                              <option value="POL" selected>Poland</option>

                              <option value="PRT" selected>Portugal</option>

                              <option value="PRI" selected>Puerto Rico</option>

                              <option value="QAT" selected>Qatar</option>

                              <option value="REU" selected>Reunion</option>

                              <option value="ROM" selected>Romania</option>

                              <option value="RUS" selected>Russian Federation</option>

                              <option value="RWA" selected>Rwanda</option>

                              <option value="KNA" selected>Saint Kitts And Nevis</option>

                              <option value="LCA" selected>Saint Lucia</option>

                              <option value="WSM" selected>Samoa</option>

                              <option value="SMR" selected>San Marino</option>

                              <option value="STP" selected>Sao Tome And Principe</option>

                              <option value="SAU" selected>Saudi Arabia</option>

                              <option value="SEN" selected>Senegal</option>

                              <option value="SYC" selected>Seychelles</option>

                              <option value="SLE" selected>Sierra Leone</option>

                              <option value="SGP" selected>Singapore</option>

                              <option value="SVK" selected>Slovakia(Slovak Republic)</option>

                              <option value="SVN" selected>Slovenia</option>

                              <option value="SLB" selected>Solomon Islands</option>

                              <option value="SOM" selected>Somalia</option>

                              <option value="ZAF" selected>South Africa</option>

                              <option value="SGS" selected>South Georgia</option>

                              <option value="ESP" selected>Spain</option>

                              <option value="LKA" selected>Sri Lanka</option>

                              <option value="VCT" selected>St Vincent And Grenadines</option>

                              <option value="SHN" selected>St. Helena</option>

                              <option value="SPM" selected>St. Pierre And Miquelon</option>

                              <option value="SDN" selected>Sudan</option>

                              <option value="SUR" selected>Suriname</option>

                              <option value="SJM" selected>Svalbard & Jan Mayen Isl</option>

                              <option value="SWZ" selected>Swaziland</option>

                              <option value="SWE" selected>Sweden</option>

                              <option value="CHE" selected>Switzerland</option>

                              <option value="SYR" selected>Syrian Arab Republic</option>

                              <option value="TWN" selected>Taiwan</option>

                              <option value="TJK" selected>Tajikistan</option>

                              <option value="TZA" selected>Tanzania-United Republic</option>

                              <option value="THA" selected>Thailand</option>

                              <option value="NLD" selected>The Netherlands</option>

                              <option value="TGO" selected>Togo</option>

                              <option value="TKL" selected>Tokelau</option>

                              <option value="TON" selected>Tonga</option>

                              <option value="TTO" selected>Trinidad And Tobago</option>

                              <option value="TUN" selected>Tunisia</option>

                              <option value="TUR" selected>Turkey</option>

                              <option value="TKM" selected>Turkmenistan</option>

                              <option value="TCA" selected>Turks And Caicos Islands</option>

                              <option value="TUV" selected>Tuvalu</option>

                              <option value="UMI" selected>U S Minor Island</option>

                              <option value="UGA" selected>Uganda</option>

                              <option value="UKR" selected>Ukraine</option>

                              <option value="ARE" selected>United Arab Emirates</option>

                              <option value="GBR" selected>United Kingdom</option>

                              <option value="USA" selected>United States</option>

                              <option value="URY" selected>Uruguay</option>

                              <option value="UZB" selected>Uzbekistan</option>

                              <option value="VUT" selected>Vanuatu</option>

                              <option value="VEN" selected>Venezuela</option>

                              <option value="VNM" selected>Vietnam</option>

                              <option value="VGB" selected>Virgin Islands (British)</option>

                              <option value="VIR" selected>Virgin Islands (U.S.)</option>

                              <option value="WLF" selected>Wallis And Futuna Islands</option>

                              <option value="ESH" selected>Western Sahara</option>

                              <option value="YEM" selected>Yemen</option>

                              <option value="YUG" selected>Yugoslavia</option>

                              <option value="ZMB" selected>Zambia</option>

                              <option value="ZWE" selected>Zimbabwe</option>

                  </select>
            </td>
      </tr>
      <tr>
            <td>Description:</td>
            <td><input type="text" class="textfield" size="30" name="DESCRIPTION" value="null"></td>
      </tr>
</table>
<br>
<input type="submit" class="button" value="Add New Events">
</form>

      <hr>
      <br><strong>Your Existing Events: 1</strong><br><br><p>
      <table width="100%" border="0">
            <tr>
                  <td bgcolor="#E8E8E8"><b>Event ID</b></td>
                  <td bgcolor="#E8E8E8"><b>Event Date</b></td>
                  <td bgcolor="#E8E8E8"><b>Description</b></td>
                  <td bgcolor="#E8E8E8"><b>EDIT</b></td>
                  <td bgcolor="#E8E8E8"><b>DELETE</b></td>
                  <td bgcolor="#E8E8E8"> </td>
            </tr>

                  <tr>
                        <td>73</td>
                        <td>2004-12-16 00:00:00.0 </td>
                        <td>I am here</td>
                        <td><a href="chapter_admin?action=update_events&eid=73">edit</td>
                        <td><a href="chapter_admin?action=delete_events&eid2=73">remove</td>

                  </tr>
                  

      </table>

            <table width="793" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                        <td align="center" bgcolor="#005AE1">
                              <span style="color: #FFFFFF; font-size: xx-small">(admin) CCIM Chapters &copy; 2005</span>
                        </td>
                  </tr>
            </table>
      <body>
</html>
0
 
ZvonkoSystems architectCommented:
I supose that you have a Script error message that you do not see.
If you show me only the one html page loaded in browser without the script files it would be the first step in remote dignosis. Mostly it works in first step...
0
 
royalcyberAuthor Commented:
Zvonko when I do view source in the browser it opens the whole code with the script files, would you know how to get only the html code

0
 
ZvonkoSystems architectCommented:
Your page works on my PC.
But of course only for Australia, Canada, Mexico and USA.

0
 
ZvonkoSystems architectCommented:
Do you know which of your .js include files contains initDynamicOptionLists() function?
Perhaps you include that function twice?
0
 
royalcyberAuthor Commented:
In order to check whether I am including the function twice. I took out all the other .js files and kept only this one

<!-- Javascript Include Files > IMPORTANT -->
            <script language="JavaScript" src="/common/javascripts/DynamicOptionList.js" type="text/javascript"></script>

But it is stll not coming

Below is the DynamicOptionList.js file

// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download.
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================

var dynamicOptionListCount=0;var dynamicOptionListObjects = new Array();
function initDynamicOptionLists(){for(var i=0;i<dynamicOptionListObjects.length;i++){var dol = dynamicOptionListObjects[i];if(dol.formName!=null){dol.form = document.forms[dol.formName];}else if(dol.formIndex!=null){dol.form = document.forms[dol.formIndex];}else{var name = dol.fieldNames[0][0];for(var f=0;f<document.forms.length;f++){if(typeof(document.forms[f][name])!="undefined"){dol.form = document.forms[f];break;}}if(dol.form==null){alert("ERROR: Couldn't find form element "+name+" in any form on the page! Init aborted");return;}}for(var j=0;j<dol.fieldNames.length;j++){for(var k=0;k<dol.fieldNames[j].length-1;k++){var selObj = dol.form[dol.fieldNames[j][k]];if(typeof(selObj)=="undefined"){alert("Select box named "+dol.fieldNames[j][k]+" could not be found in the form. Init aborted");return;}if(k==0){if(selObj.options!=null){for(l=0;l<selObj.options.length;l++){var sopt = selObj.options[l];var m = dol.findMatchingOptionInArray(dol.options,sopt.text,sopt.value,false);if(m!=null){var reselectForNN6 = sopt.selected;var m2 = new Option(sopt.text, sopt.value, sopt.defaultSelected, sopt.selected);m2.selected = sopt.selected;m2.defaultSelected = sopt.defaultSelected;m2.DOLOption = m;selObj.options[l] = m2;selObj.options[l].selected = reselectForNN6;}}}}if(selObj.onchange==null){selObj.onchange = new Function("dynamicOptionListObjects["+dol.index+"].change(this)");}}}}resetDynamicOptionLists();}
function resetDynamicOptionLists(theform){for(var i=0;i<dynamicOptionListObjects.length;i++){var dol = dynamicOptionListObjects[i];if(typeof(theform)=="undefined" || theform==null || theform==dol.form){for(var j=0;j<dol.fieldNames.length;j++){dol.change(dol.form[dol.fieldNames[j][0]],true);}}}}
function DOLOption(text,value,defaultSelected,selected){this.text = text;this.value = value;this.defaultSelected = defaultSelected;this.selected = selected;this.options = new Array();return this;}
function DynamicOptionList(){this.form = null;this.options = new Array();this.longestString = new Array();this.numberOfOptions = new Array();this.currentNode = null;this.currentField = null;this.currentNodeDepth = 0;this.fieldNames = new Array();this.formIndex = null;this.formName = null;this.fieldListIndexes = new Object();this.fieldIndexes = new Object();this.selectFirstOption = true;this.numberOfOptions = new Array();this.longestString = new Array();this.values = new Object();this.forValue = DOL_forValue;this.forText = DOL_forText;this.forField = DOL_forField;this.forX = DOL_forX;this.addOptions = DOL_addOptions;this.addOptionsTextValue = DOL_addOptionsTextValue;this.setDefaultOptions = DOL_setDefaultOptions;this.setValues = DOL_setValues;this.setValue = DOL_setValues;this.setFormIndex = DOL_setFormIndex;this.setFormName = DOL_setFormName;this.printOptions = DOL_printOptions;this.addDependentFields = DOL_addDependentFields;this.change = DOL_change;this.child = DOL_child;this.selectChildOptions = DOL_selectChildOptions;this.populateChild = DOL_populateChild;this.change = DOL_change;this.addNewOptionToList = DOL_addNewOptionToList;this.findMatchingOptionInArray = DOL_findMatchingOptionInArray;if(arguments.length > 0){for(var i=0;i<arguments.length;i++){this.fieldListIndexes[arguments[i].toString()] = this.fieldNames.length;this.fieldIndexes[arguments[i].toString()] = i;}this.fieldNames[this.fieldNames.length] = arguments;}this.index = window.dynamicOptionListCount++;window["dynamicOptionListObjects"][this.index] = this;}
function DOL_findMatchingOptionInArray(a,text,value,exactMatchRequired){if(a==null || typeof(a)=="undefined"){return null;}var value_match = null;var text_match = null;for(var i=0;i<a.length;i++){var opt = a[i];if(opt.value==value && opt.text==text){return opt;}if(!exactMatchRequired){if(value_match==null && value!=null && opt.value==value){value_match = opt;}if(text_match==null && text!=null && opt.text==text){text_match = opt;}}}return(value_match!=null)?value_match:text_match;}
function DOL_forX(s,type){if(this.currentNode==null){this.currentNodeDepth=0;}var useNode =(this.currentNode==null)?this:this.currentNode;var o = this.findMatchingOptionInArray(useNode["options"],(type=="text")?s:null,(type=="value")?s:null,false);if(o==null){o = new DOLOption(null,null,false,false);o[type] = s;useNode.options[useNode.options.length] = o;}this.currentNode = o;this.currentNodeDepth++;return this;}
function DOL_forValue(s){return this.forX(s,"value");}
function DOL_forText(s){return this.forX(s,"text");}
function DOL_forField(f){this.currentField = f;return this;}
function DOL_addNewOptionToList(a, text, value, defaultSelected){var o = new DOLOption(text,value,defaultSelected,false);if(a==null){a = new Array();}for(var i=0;i<a.length;i++){if(a[i].text==o.text && a[i].value==o.value){if(o.selected){a[i].selected=true;}if(o.defaultSelected){a[i].defaultSelected = true;}return a;}}a[a.length] = o;}
function DOL_addOptions(){if(this.currentNode==null){this.currentNode = this;}if(this.currentNode["options"] == null){this.currentNode["options"] = new Array();}for(var i=0;i<arguments.length;i++){var text = arguments[i];this.addNewOptionToList(this.currentNode.options,text,text,false);if(typeof(this.numberOfOptions[this.currentNodeDepth])=="undefined"){this.numberOfOptions[this.currentNodeDepth]=0;}if(this.currentNode.options.length > this.numberOfOptions[this.currentNodeDepth]){this.numberOfOptions[this.currentNodeDepth] = this.currentNode.options.length;}if(typeof(this.longestString[this.currentNodeDepth])=="undefined" ||(text.length > this.longestString[this.currentNodeDepth].length)){this.longestString[this.currentNodeDepth] = text;}}this.currentNode = null;this.currentNodeDepth = 0;}
function DOL_addOptionsTextValue(){if(this.currentNode==null){this.currentNode = this;}if(this.currentNode["options"] == null){this.currentNode["options"] = new Array();}for(var i=0;i<arguments.length;i++){var text = arguments[i++];var value = arguments[i];this.addNewOptionToList(this.currentNode.options,text,value,false);if(typeof(this.numberOfOptions[this.currentNodeDepth])=="undefined"){this.numberOfOptions[this.currentNodeDepth]=0;}if(this.currentNode.options.length > this.numberOfOptions[this.currentNodeDepth]){this.numberOfOptions[this.currentNodeDepth] = this.currentNode.options.length;}if(typeof(this.longestString[this.currentNodeDepth])=="undefined" ||(text.length > this.longestString[this.currentNodeDepth].length)){this.longestString[this.currentNodeDepth] = text;}}this.currentNode = null;this.currentNodeDepth = 0;}
function DOL_child(obj){var listIndex = this.fieldListIndexes[obj.name];var index = this.fieldIndexes[obj.name];if(index <(this.fieldNames[listIndex].length-1)){return this.form[this.fieldNames[listIndex][index+1]];}return null;}
function DOL_setDefaultOptions(){if(this.currentNode==null){this.currentNode = this;}for(var i=0;i<arguments.length;i++){var o = this.findMatchingOptionInArray(this.currentNode.options,null,arguments[i],false);if(o!=null){o.defaultSelected = true;}}this.currentNode = null;}
function DOL_setValues(){if(this.currentField==null){alert("Can't call setValues() without using forField() first!");return;}if(typeof(this.values[this.currentField])=="undefined"){this.values[this.currentField] = new Object();}for(var i=0;i<arguments.length;i++){this.values[this.currentField][arguments[i]] = true;}this.currentField = null;}
function DOL_setFormIndex(i){this.formIndex = i;}
function DOL_setFormName(n){this.formName = n;}
function DOL_printOptions(name){if((navigator.appName == 'Netscape') &&(parseInt(navigator.appVersion) <= 4)){var index = this.fieldIndexes[name];var ret = "";if(typeof(this.numberOfOptions[index])!="undefined"){for(var i=0;i<this.numberOfOptions[index];i++){ret += "<OPTION>";}}ret += "<OPTION>";if(typeof(this.longestString[index])!="undefined"){for(var i=0;i<this.longestString[index].length;i++){ret += "_";}}document.writeln(ret);}}
function DOL_addDependentFields(){for(var i=0;i<arguments.length;i++){this.fieldListIndexes[arguments[i].toString()] = this.fieldNames.length;this.fieldIndexes[arguments[i].toString()] = i;}this.fieldNames[this.fieldNames.length] = arguments;}
function DOL_change(obj, usePreselected){if(usePreselected==null || typeof(usePreselected)=="undefined"){usePreselected = false;}var changedListIndex = this.fieldListIndexes[obj.name];var changedIndex = this.fieldIndexes[obj.name];var child = this.child(obj);if(child == null){return;}if(obj.type == "select-one"){if(child.options!=null){child.options.length=0;}if(obj.options!=null && obj.options.length>0 && obj.selectedIndex>=0){var o = obj.options[obj.selectedIndex];this.populateChild(o.DOLOption,child,usePreselected);this.selectChildOptions(child,usePreselected);}}else if(obj.type == "select-multiple"){var currentlySelectedOptions = new Array();if(!usePreselected){for(var i=0;i<child.options.length;i++){var co = child.options[i];if(co.selected){this.addNewOptionToList(currentlySelectedOptions, co.text, co.value, co.defaultSelected);}}}child.options.length=0;if(obj.options!=null){var obj_o = obj.options;for(var i=0;i<obj_o.length;i++){if(obj_o[i].selected){this.populateChild(obj_o[i].DOLOption,child,usePreselected);}}var atLeastOneSelected = false;if(!usePreselected){for(var i=0;i<child.options.length;i++){var m = this.findMatchingOptionInArray(currentlySelectedOptions,child.options[i].text,child.options[i].value,true);if(m!=null){child.options[i].selected = true;atLeastOneSelected = true;}}}if(!atLeastOneSelected){this.selectChildOptions(child,usePreselected);}}}this.change(child,usePreselected);}
function DOL_populateChild(dolOption,childSelectObj,usePreselected){if(dolOption!=null && dolOption.options!=null){for(var j=0;j<dolOption.options.length;j++){var srcOpt = dolOption.options[j];if(childSelectObj.options==null){childSelectObj.options = new Array();}var duplicate = false;var preSelectedExists = false;for(var k=0;k<childSelectObj.options.length;k++){var csi = childSelectObj.options[k];if(csi.text==srcOpt.text && csi.value==srcOpt.value){duplicate = true;break;}}if(!duplicate){var newopt = new Option(srcOpt.text, srcOpt.value, false, false);newopt.selected = false;newopt.defaultSelected = false;newopt.DOLOption = srcOpt;childSelectObj.options[childSelectObj.options.length] = newopt;}}}}
function DOL_selectChildOptions(obj,usePreselected){var values = this.values[obj.name];var preselectedExists = false;if(usePreselected && values!=null && typeof(values)!="undefined"){for(var i=0;i<obj.options.length;i++){var v = obj.options[i].value;if(v!=null && values[v]!=null && typeof(values[v])!="undefined"){preselectedExists = true;break;}}}var atLeastOneSelected = false;for(var i=0;i<obj.options.length;i++){var o = obj.options[i];if(preselectedExists && o.value!=null && values[o.value]!=null && typeof(values[o.value])!="undefined"){o.selected = true;atLeastOneSelected = true;}else if(!preselectedExists && o.DOLOption!=null && o.DOLOption.defaultSelected){o.selected = true;atLeastOneSelected = true;}else{o.selected = false;}}if(this.selectFirstOption && !atLeastOneSelected && obj.options.length>0){obj.options[0].selected = true;}else if(!atLeastOneSelected &&  obj.type=="select-one"){obj.selectedIndex = -1;}}

0
 
ZvonkoSystems architectCommented:
As I stated, it works for me.
So any of the nine other includes has a script error or does overload some methods or values.
0
 
royalcyberAuthor Commented:
I deleted all the other methods as I was not using them for this application but still it doesn't show up.

Would you know how should I go about debugging this? I am not sure why it is not working for me but I checked the code twice again
ad culdn't dfind any error

here is the table row again

<tr>
            <td>ZIP:</td>
            <td><input type="text" class="textfield" size="30" name= "ZIP" value="<%= selected_event.getZip()%>" maxlength="80"></td>
      
            <td>Country: <font color="red">*</font></td>
            <td>
                  <select name="country" class="textfield">
                        <option value="0">* Select One *</option>
<%
                        for(int key_index = 0; key_index < country_keys.length; key_index++) {
                              String next_key   = (String)country_keys[key_index];
                              String next_value = (String)countries.get(next_key);
%>
                              <option value="<%=next_key%>" selected><%= next_value %></option>
<%                        } %>
                  </select>
            </td>

            <td>State/Province: <font color="red">*</font></td>
            <td><select name="state"><script>states.printOptions("state")</script></select></td>
      </tr>
0
 
ZvonkoSystems architectCommented:
Open your page in IE and save it like this: File->SaveAs [type: WebArchive:singleFile]
Sind me that file to the email address in my member profile.
0
 
royalcyberAuthor Commented:
Sorry, but I couldn't find your email address in your profile.

Also I found 2 script errors on the browser

1) DynamicOptionList is undefined

2) 'states' is null or not an object

Thanks
0
 
ZvonkoSystems architectCommented:
Remove the blanks following the zp and you will see an email address.
0
 
royalcyberAuthor Commented:
Zvonko I am not able to attach the .mht file. I tried 3 differnt email accounts but couldn't do so.
0
 
royalcyberAuthor Commented:
I managed to zip the file and send it
0
 
ZvonkoSystems architectCommented:
I got it.
After I inserted the file name here all worked well:
<SCRIPT language=JavaScript src="" type=text/javascript></SCRIPT>

What file name do you have there in quotes?


0
 
ZvonkoSystems architectCommented:
What happens when you enter this URL in your browser: http://localhost/common/javascripts/DynamicOptionList.js
Do you get that file offered for download?

0
 
ZvonkoSystems architectCommented:
Seams it was a long running trivia ;-)
0
 
royalcyberAuthor Commented:
Thanks for all your help. The fle was actually misplaced
0
 
ZvonkoSystems architectCommented:
You are welcome.
0
 
royalcyberAuthor Commented:
Zvonka I had another question also

Currently I am collecting date from the user using a text field and it is stored in the databse as Date/Time field. Now I need to
collect the date from the user as month, day , and year all seperately and then combine it and store it as date/time field in SQL Server.

Would you know any tutorial or opensource code which I can use to accomplish this. Also  I am opening a new question for this, so please reply in that
so that I can give you extra points for this and also other people can benefit.

Thanks
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 18
  • 12
Tackle projects and never again get stuck behind a technical roadblock.
Join Now