#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    Problem populating textbox from input of select boxes


    Hi,

    I want to take input from selectbox 1 (1st country) and another input from selectbox2 (2nd country) and display the result in the textbox or somewhere! there are over 200 countries, remember!

    Example:

    Bangladesh INTERNATIONAL DIALING CODES is 88 and
    USA INTERNATIONAL DIALING CODES is 1.

    When you call to Bangladesh from USA it becomes 011 880 X and When you call to USA from Bangladesh it becomes 00 1 X.


    thanks.

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
    <script>
    
    function CountryCodeFunction(dropdown, textbox)
    {
        var myindex  = dropdown.selectedIndex
        var SelValue = dropdown.options[myindex].value
        if (SelValue == "BD")
        {
          textbox.value = "+88"
        }
        else if (SelValue == "US")
        {
          textbox.value = "+1"
        }
        return true;
    }
    
    
    </script>
    
    </head>
    
    <table>
      <tr>
    <td>From:</td>
    <td>
    <form name="form">
    <select name="from" id="from" onChange="CountryCodeFunction(this.form.from, this.form.phonenumber)">
    <option value="BD">Bangladesh</option><option value="US">USA</option>
    </select>
      <input type="text" name="phonenumber" value="+88">
      </form>
    </td>
     </tr>
     
      <tr>
    <td>To:</td>
    <td>
    
    <select name="to" id="to">
    <option value="US">USA</option><option value="BD">Bangladesh</option>
    </select>
    </td>
      </tr>
       <tr>
    <td>
    
    
    <p id="pcode">
    
    </p>
    
    
    
    
    </td>
    
      </tr>
      </table>
    
    
    
    </body>
    </html>
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,110
    Rep Power
    119
    You mean something like this:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
    <script>
    
    function CountryCodeFunction(dropdown1, dropdown2, textbox)
    {
        var from = dropdown1.selectedIndex;
        var to = dropdown2.selectedIndex;
        var SelValue1 = dropdown1.options[from].value;
        var SelValue2 = dropdown2.options[to].value;
        if (SelValue1 == "BD" && SelValue2 == "US")
        {
          textbox.value = "+88"
          document.getElementById("pcode").innerHTML = "011 880 X";
        }
        else if (SelValue1 == "US" && SelValue2 == "BD")
        {
          textbox.value = "+1";
          document.getElementById("pcode").innerHTML = "00 1 X";
        }
        return true;
    }
    
    
    </script>
    
    </head>
    
    <table>
      <tr>
    <td>From:</td>
    <td>
    <form name="form">
    <select name="from" id="from" onChange="CountryCodeFunction(this.form.from, this.form.to, this.form.phonenumber)">
    <option selected>Calling From</option>
    <option value="BD">Bangladesh</option>
    <option value="US">USA</option>
    </select>
      <input type="text" name="phonenumber" value="+88">
    </td>
     </tr>
     
      <tr>
    <td>To:</td>
    <td>
    
    <select name="to" id="to" onChange="CountryCodeFunction(this.form.from, this.form.to, this.form.phonenumber)">
    <option selected>Calling To</option>
    <option value="US">USA</option>
    <option value="BD">Bangladesh</option>
    </select>
      </form>
    </td>
      </tr>
       <tr>
    <td>
    
    
    <p id="pcode">
    
    </p>
    
    
    
    
    </td>
    
      </tr>
      </table>
    
    
    
    </body>
    </html>
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0
    Yes, something like this. But not exactly like this. You missed my point there are over 200 countries, remember!

    The code will be HUGE!

    Can you create arrays from the below and input in the code below: (Couldn't complete list for 30000 words limit)

    Country name codes:
    'BD','TN','TR','TM','TV','UG','UA','AE','GB','US','UY','UZ','VU','VE','VN','VG','WF','YE','ZM','ZW'

    Country Codes:
    '93','43','994','1242','973','880','1246','375','32','501','598','998','678','58','84','1284','681', '967','260','263'

    These are added before the country codes for dialing FROM :
    '00', '011', '011', '00', '0011', '00', '00', '011', '00', '00', '011', '8', '00', '00', '00', '011', '00', '00', '8', '000'
    Example for BD the code is 88. Most FROM countries will dial 00+code while FROM USA it is 011+code. You put it in an array, the code shrinks rapidly.

    Note: Only Bangladesh and USA are working!

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>ISD Dialing Codes</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script>
    function CountryCodeFunction(dropdown1, dropdown2, textbox)
    {
        var from = dropdown1.selectedIndex;
        var to = dropdown2.selectedIndex;
        var SelValue1 = dropdown1.options[from].value;
        var SelValue2 = dropdown2.options[to].value;
        if (SelValue1 == "BD" && SelValue2 == "US")
        {
          textbox.value = "001 X";
        }
        else if (SelValue1 == "US" && SelValue2 == "BD")
        {
          textbox.value = "011880 X";
    	} 
    	else if (SelValue1 == SelValue2)
        {
          textbox.value = "Invalid!";
    	} 
    	else
    	{
    	  textbox.value = "";
        }
        return true;
    }
    </script>
    </head>
    <body>
    <table>
      <tr>
      <td>From:</td>
    <td>
    <form name="form">
    <select name="from" id="from" onChange="CountryCodeFunction(this.form.from, this.form.to, this.form.phonenumber)">
    <option style="width:100px" value="AF" >Afghanistan</option><option style="width:100px" value="AL" >Albania</option><option style="width:100px" value="DZ" >Algeria</option><option style="width:100px" value="AD" >Andorra</option><option style="width:100px" value="AO" >Angola</option><option style="width:100px" value="AI" >Anguilla</option><option style="width:100px" value="AG" >Antigua & Barbuda</option><option style="width:100px" value="AR" >Argentina</option><option style="width:100px" value="AM" >Armenia</option><option style="width:100px" value="AW" >Aruba</option><option style="width:100px" value="AU" >Australia</option><option style="width:100px" value="AT" >Austria</option><option style="width:100px" value="AZ" >Azerbaijan</option><option style="width:100px" value="BS" >Bahamas</option><option style="width:100px" value="BH" >Bahrain</option><option style="width:100px" value="BD" SELECTED >Bangladesh</option><option style="width:100px" value="BB" >Barbados</option><option style="width:100px" value="BY" >Belarus</option><option style="width:100px" value="BE" >Belgium</option><option style="width:100px" value="BZ" >Belize</option><option style="width:100px" value="BJ" >Benin</option><option style="width:100px" value="BM" >Bermuda</option><option style="width:100px" value="BT" >Bhutan</option><option style="width:100px" value="BO" >Bolivia</option><option style="width:100px" value="BA" >Bosnia & Herzegovina</option><option style="width:100px" value="BW" >Botswana</option><option style="width:100px" value="BR" >Brazil</option><option style="width:100px" value="BN" >Brunei</option><option style="width:100px" value="BG" >Bulgaria</option><option style="width:100px" value="BF" >Burkina Faso</option><option style="width:100px" value="BI" >Burundi</option><option style="width:100px" value="KH" >Cambodia</option><option style="width:100px" value="CM" >Cameroon</option><option style="width:100px" value="CA" >Canada</option><option style="width:100px" value="CV" >Cape Verde</option><option style="width:100px" value="KY" >Cayman Islands</option><option style="width:100px" value="CF" >Central African Rep.</option><option style="width:100px" value="TD" >Chad</option><option style="width:100px" value="CL" >Chile</option><option style="width:100px" value="CN" >China</option><option style="width:100px" value="CX" >Christmas Island</option><option style="width:100px" value="CC" >Cocos (Keeling) Islands</option><option style="width:100px" value="CO" >Colombia</option><option style="width:100px" value="KM" >Comoros</option><option style="width:100px" value="CD" >Congo (Dem. Rep.)</option><option style="width:100px" value="CG" >Congo (Rep.)</option><option style="width:100px" value="CK" >Cook Islands</option><option style="width:100px" value="CR" >Costa Rica</option><option style="width:100px" value="CI" >Cote d\'Ivoire</option><option style="width:100px" value="HR" >Croatia</option><option style="width:100px" value="CU" >Cuba</option><option style="width:100px" value="CY" >Cyprus</option><option style="width:100px" value="CZ" >Czech Republic</option><option style="width:100px" value="DK" >Denmark</option><option style="width:100px" value="DJ" >Djibouti</option><option style="width:100px" value="DM" >Dominica</option><option style="width:100px" value="DO" >Dominican Republic</option><option style="width:100px" value="TL" >East Timor</option><option style="width:100px" value="EC" >Ecuador</option><option style="width:100px" value="EG" >Egypt</option><option style="width:100px" value="SV" >El Salvador</option><option style="width:100px" value="GQ" >Equatorial Guinea</option><option style="width:100px" value="ER" >Eritrea</option><option style="width:100px" value="EE" >Estonia</option><option style="width:100px" value="ET" >Ethiopia</option><option style="width:100px" value="FO" >Faeroe Islands</option><option style="width:100px" value="FK" >Falkland Islands</option><option style="width:100px" value="FJ" >Fiji</option><option style="width:100px" value="FI" >Finland</option><option style="width:100px" value="FR" >France</option><option style="width:100px" value="GF" >French Guiana</option><option style="width:100px" value="PF" >French Polynesia</option><option style="width:100px" value="GA" >Gabon</option><option style="width:100px" value="GM" >Gambia</option><option style="width:100px" value="GE" >Georgia</option><option style="width:100px" value="DE" >Germany</option><option style="width:100px" value="GH" >Ghana</option><option style="width:100px" value="GI" >Gibraltar</option><option style="width:100px" value="GR" >Greece</option><option style="width:100px" value="GL" >Greenland</option><option style="width:100px" value="GD" >Grenada</option><option style="width:100px" value="GP" >Guadeloupe</option><option style="width:100px" value="GU" >Guam</option><option style="width:100px" value="GT" >Guatemala</option><option style="width:100px" value="GN" >Guinea</option><option style="width:100px" value="GW" >Guinea Bissau</option><option style="width:100px" value="GY" >Guyana</option><option style="width:100px" value="HT" >Haiti</option><option style="width:100px" value="HN" >Honduras</option><option style="width:100px" value="HK" >Hong Kong</option><option style="width:100px" value="HU" >Hungary</option><option style="width:100px" value="IS" >Iceland</option><option style="width:100px" value="IN" >India</option><option style="width:100px" value="ID" >Indonesia</option><option style="width:100px" value="IR" >Iran</option><option style="width:100px" value="IQ" >Iraq</option><option style="width:100px" value="IE" >Ireland</option><option style="width:100px" value="IM" >Isle of Man</option><option style="width:100px" value="IL" >Israel</option><option style="width:100px" value="IT" >Italy</option><option style="width:100px" value="JM" >Jamaica</option><option style="width:100px" value="JP" >Japan</option><option style="width:100px" value="JO" >Jordan</option><option style="width:100px" value="KZ" >Kazakhstan</option><option style="width:100px" value="KE" >Kenya</option><option style="width:100px" value="KI" >Kiribati</option><option style="width:100px" value="KP" >Korea (North)</option><option style="width:100px" value="KR" >Korea (South)</option><option style="width:100px" value="KW" >Kuwait</option><option style="width:100px" value="KG" >Kyrgyzstan</option><option style="width:100px" value="LA" >Laos</option><option style="width:100px" value="LV" >Latvia</option><option style="width:100px" value="LB" >Lebanon</option><option style="width:100px" value="LS" >Lesotho</option><option style="width:100px" value="LR" >Liberia</option><option style="width:100px" value="LY" >Libya</option><option style="width:100px" value="LI" >Liechtenstein</option><option style="width:100px" value="LT" >Lithuania</option><option style="width:100px" value="LU" >Luxembourg</option><option style="width:100px" value="MO" >Macau</option><option style="width:100px" value="MK" >Macedonia</option><option style="width:100px" value="MG" >Madagascar</option><option style="width:100px" value="MW" >Malawi</option><option style="width:100px" value="MY" >Malaysia</option><option style="width:100px" value="MV" >Maldives</option><option style="width:100px" value="ML" >Mali</option><option style="width:100px" value="MT" >Malta</option><option style="width:100px" value="MH" >Marshall Islands</option><option style="width:100px" value="MQ" >Martinique</option><option style="width:100px" value="MR" >Mauritania</option><option style="width:100px" value="MU" >Mauritius</option><option style="width:100px" value="YT" >Mayotte</option><option style="width:100px" value="MX" >Mexico</option><option style="width:100px" value="FM" >Micronesia</option><option style="width:100px" value="MD" >Moldova</option><option style="width:100px" value="MC" >Monaco</option><option style="width:100px" value="MN" >Mongolia</option><option style="width:100px" value="ME" >Montenegro</option><option style="width:100px" value="MS" >Montserrat</option><option style="width:100px" value="MA" >Morocco</option><option style="width:100px" value="MZ" >Mozambique</option><option style="width:100px" value="MM" >Myanmar (Burma)</option><option style="width:100px" value="NA" >Namibia</option><option style="width:100px" value="NR" >Nauru</option><option style="width:100px" value="NP" >Nepal</option><option style="width:100px" value="NL" >Netherlands</option><option style="width:100px" value="AN" >Netherlands Antilles</option><option style="width:100px" value="NC" >New Caledonia</option><option style="width:100px" value="NZ" >New Zealand</option><option style="width:100px" value="NI" >Nicaragua</option><option style="width:100px" value="NE" >Niger</option><option style="width:100px" value="NG" >Nigeria</option><option style="width:100px" value="NU" >Niue</option><option style="width:100px" value="NF" >Norfolk Island</option><option style="width:100px" value="MP" >Northern Mariana Islands</option><option style="width:100px" value="NO" >Norway</option><option style="width:100px" value="OM" >Oman</option><option style="width:100px" value="PK" >Pakistan</option><option style="width:100px" value="PW" >Palau</option><option style="width:100px" value="PS" >Palestine</option><option style="width:100px" value="PA" >Panama</option><option style="width:100px" value="PG" >Papua New Guinea</option><option style="width:100px" value="PY" >Paraguay</option><option style="width:100px" value="PE" >Peru</option><option style="width:100px" value="PH" >Philippines</option><option style="width:100px" value="PL" >Poland</option><option style="width:100px" value="PT" >Portugal</option><option style="width:100px" value="PR" >Puerto Rico</option><option style="width:100px" value="QA" >Qatar</option><option style="width:100px" value="RO" >Romania</option><option style="width:100px" value="RU" >Russia</option><option style="width:100px" value="RW" >Rwanda</option><option style="width:100px" value="AS" >Samoa (American)</option><option style="width:100px" value="WS" >Samoa (western)</option><option style="width:100px" value="SM" >San Marino</option><option style="width:100px" value="ST" >Sao Tome & Principe</option><option style="width:100px" value="SA" >Saudi Arabia</option><option style="width:100px" value="SN" >Senegal</option><option style="width:100px" value="RS" >Serbia</option><option style="width:100px" value="CS" >Serbia and Montenegro</option><option style="width:100px" value="SC" >Seychelles</option><option style="width:100px" value="SL" >Sierra Leone</option><option style="width:100px" value="SG" >Singapore</option><option style="width:100px" value="SK" >Slovakia</option><option style="width:100px" value="SI" >Slovenia</option><option style="width:100px" value="SB" >Solomon Islands</option><option style="width:100px" value="SO" >Somalia</option><option style="width:100px" value="ZA" >South Africa</option><option style="width:100px" value="ES" >Spain</option><option style="width:100px" value="LK" >Sri Lanka</option><option style="width:100px" value="SH" >St Helena</option><option style="width:100px" value="SD" >Sudan</option><option style="width:100px" value="SR" >Suriname</option><option style="width:100px" value="SZ" >Swaziland</option><option style="width:100px" value="SE" >Sweden</option><option style="width:100px" value="CH" >Switzerland</option><option style="width:100px" value="SY" >Syria</option><option style="width:100px" value="TW" >Taiwan</option><option style="width:100px" value="TJ" >Tajikistan</option><option style="width:100px" value="TZ" >Tanzania</option><option style="width:100px" value="TH" >Thailand</option><option style="width:100px" value="TG" >Togo</option><option style="width:100px" value="TK" >Tokelau</option><option style="width:100px" value="TO" >Tonga</option><option style="width:100px" value="TT" >Trinidad & Tobago</option><option style="width:100px" value="TN" >Tunisia</option><option style="width:100px" value="TR" >Turkey</option><option style="width:100px" value="TM" >Turkmenistan</option><option style="width:100px" value="TV" >Tuvalu</option><option style="width:100px" value="UG" >Uganda</option><option style="width:100px" value="UA" >Ukraine</option><option style="width:100px" value="AE" >United Arab Emirates</option><option style="width:100px" value="GB" >United Kingdom</option><option style="width:100px" value="US" >United States</option><option style="width:100px" value="UY" >Uruguay</option><option style="width:100px" value="UZ" >Uzbekistan</option><option style="width:100px" value="VU" >Vanuatu</option><option style="width:100px" value="VE" >Venezuela</option><option style="width:100px" value="VN" >Vietnam</option><option style="width:100px" value="VG" >Virgin Islands (UK)</option><option style="width:100px" value="WF" >Wallis & Futuna</option><option style="width:100px" value="YE" >Yemen</option><option style="width:100px" value="ZM" >Zambia</option><option style="width:100px" value="ZW" >Zimbabwe</option>
    </select>
     </td>
     </tr>
       <tr>
       <td>To:</td>
    <td>
    <select name="to" id="to" onChange="CountryCodeFunction(this.form.from, this.form.to, this.form.phonenumber)">
    <option style="width:100px" value="AF" >Afghanistan</option><option style="width:100px" value="AL" >Albania</option><option style="width:100px" value="DZ" >Algeria</option><option style="width:100px" value="AD" >Andorra</option><option style="width:100px" value="AO" >Angola</option><option style="width:100px" value="AI" >Anguilla</option><option style="width:100px" value="AG" >Antigua & Barbuda</option><option style="width:100px" value="AR" >Argentina</option><option style="width:100px" value="AM" >Armenia</option><option style="width:100px" value="AW" >Aruba</option><option style="width:100px" value="AU" >Australia</option><option style="width:100px" value="AT" >Austria</option><option style="width:100px" value="AZ" >Azerbaijan</option><option style="width:100px" value="BS" >Bahamas</option><option style="width:100px" value="BH" >Bahrain</option><option style="width:100px" value="BD" >Bangladesh</option><option style="width:100px" value="BB" >Barbados</option><option style="width:100px" value="BY" >Belarus</option><option style="width:100px" value="BE" >Belgium</option><option style="width:100px" value="BZ" >Belize</option><option style="width:100px" value="BJ" >Benin</option><option style="width:100px" value="BM" >Bermuda</option><option style="width:100px" value="BT" >Bhutan</option><option style="width:100px" value="BO" >Bolivia</option><option style="width:100px" value="BA" >Bosnia & Herzegovina</option><option style="width:100px" value="BW" >Botswana</option><option style="width:100px" value="BR" >Brazil</option><option style="width:100px" value="BN" >Brunei</option><option style="width:100px" value="BG" >Bulgaria</option><option style="width:100px" value="BF" >Burkina Faso</option><option style="width:100px" value="BI" >Burundi</option><option style="width:100px" value="KH" >Cambodia</option><option style="width:100px" value="CM" >Cameroon</option><option style="width:100px" value="CA" >Canada</option><option style="width:100px" value="CV" >Cape Verde</option><option style="width:100px" value="KY" >Cayman Islands</option><option style="width:100px" value="CF" >Central African Rep.</option><option style="width:100px" value="TD" >Chad</option><option style="width:100px" value="CL" >Chile</option><option style="width:100px" value="CN" >China</option><option style="width:100px" value="CX" >Christmas Island</option><option style="width:100px" value="CC" >Cocos (Keeling) Islands</option><option style="width:100px" value="CO" >Colombia</option><option style="width:100px" value="KM" >Comoros</option><option style="width:100px" value="CD" >Congo (Dem. Rep.)</option><option style="width:100px" value="CG" >Congo (Rep.)</option><option style="width:100px" value="CK" >Cook Islands</option><option style="width:100px" value="CR" >Costa Rica</option><option style="width:100px" value="CI" >Cote d\'Ivoire</option><option style="width:100px" value="HR" >Croatia</option><option style="width:100px" value="CU" >Cuba</option><option style="width:100px" value="CY" >Cyprus</option><option style="width:100px" value="CZ" >Czech Republic</option><option style="width:100px" value="DK" >Denmark</option><option style="width:100px" value="DJ" >Djibouti</option><option style="width:100px" value="DM" >Dominica</option><option style="width:100px" value="DO" >Dominican Republic</option><option style="width:100px" value="TL" >East Timor</option><option style="width:100px" value="EC" >Ecuador</option><option style="width:100px" value="EG" >Egypt</option><option style="width:100px" value="SV" >El Salvador</option><option style="width:100px" value="GQ" >Equatorial Guinea</option><option style="width:100px" value="ER" >Eritrea</option><option style="width:100px" value="EE" >Estonia</option><option style="width:100px" value="ET" >Ethiopia</option><option style="width:100px" value="FO" >Faeroe Islands</option><option style="width:100px" value="FK" >Falkland Islands</option><option style="width:100px" value="FJ" >Fiji</option><option style="width:100px" value="FI" >Finland</option><option style="width:100px" value="FR" >France</option><option style="width:100px" value="GF" >French Guiana</option><option style="width:100px" value="PF" >French Polynesia</option><option style="width:100px" value="GA" >Gabon</option><option style="width:100px" value="GM" >Gambia</option><option style="width:100px" value="GE" >Georgia</option><option style="width:100px" value="DE" >Germany</option><option style="width:100px" value="GH" >Ghana</option><option style="width:100px" value="GI" >Gibraltar</option><option style="width:100px" value="GR" >Greece</option><option style="width:100px" value="GL" >Greenland</option><option style="width:100px" value="GD" >Grenada</option><option style="width:100px" value="GP" >Guadeloupe</option><option style="width:100px" value="GU" >Guam</option><option style="width:100px" value="GT" >Guatemala</option><option style="width:100px" value="GN" >Guinea</option><option style="width:100px" value="GW" >Guinea Bissau</option><option style="width:100px" value="GY" >Guyana</option><option style="width:100px" value="HT" >Haiti</option><option style="width:100px" value="HN" >Honduras</option><option style="width:100px" value="HK" >Hong Kong</option><option style="width:100px" value="HU" >Hungary</option><option style="width:100px" value="IS" >Iceland</option><option style="width:100px" value="IN" >India</option><option style="width:100px" value="ID" >Indonesia</option><option style="width:100px" value="IR" >Iran</option><option style="width:100px" value="IQ" >Iraq</option><option style="width:100px" value="IE" >Ireland</option><option style="width:100px" value="IM" >Isle of Man</option><option style="width:100px" value="IL" >Israel</option><option style="width:100px" value="IT" >Italy</option><option style="width:100px" value="JM" >Jamaica</option><option style="width:100px" value="JP" >Japan</option><option style="width:100px" value="JO" >Jordan</option><option style="width:100px" value="KZ" >Kazakhstan</option><option style="width:100px" value="KE" >Kenya</option><option style="width:100px" value="KI" >Kiribati</option><option style="width:100px" value="KP" >Korea (North)</option><option style="width:100px" value="KR" >Korea (South)</option><option style="width:100px" value="KW" >Kuwait</option><option style="width:100px" value="KG" >Kyrgyzstan</option><option style="width:100px" value="LA" >Laos</option><option style="width:100px" value="LV" >Latvia</option><option style="width:100px" value="LB" >Lebanon</option><option style="width:100px" value="LS" >Lesotho</option><option style="width:100px" value="LR" >Liberia</option><option style="width:100px" value="LY" >Libya</option><option style="width:100px" value="LI" >Liechtenstein</option><option style="width:100px" value="LT" >Lithuania</option><option style="width:100px" value="LU" >Luxembourg</option><option style="width:100px" value="MO" >Macau</option><option style="width:100px" value="MK" >Macedonia</option><option style="width:100px" value="MG" >Madagascar</option><option style="width:100px" value="MW" >Malawi</option><option style="width:100px" value="MY" >Malaysia</option><option style="width:100px" value="MV" >Maldives</option><option style="width:100px" value="ML" >Mali</option><option style="width:100px" value="MT" >Malta</option><option style="width:100px" value="MH" >Marshall Islands</option><option style="width:100px" value="MQ" >Martinique</option><option style="width:100px" value="MR" >Mauritania</option><option style="width:100px" value="MU" >Mauritius</option><option style="width:100px" value="YT" >Mayotte</option><option style="width:100px" value="MX" >Mexico</option><option style="width:100px" value="FM" >Micronesia</option><option style="width:100px" value="MD" >Moldova</option><option style="width:100px" value="MC" >Monaco</option><option style="width:100px" value="MN" >Mongolia</option><option style="width:100px" value="ME" >Montenegro</option><option style="width:100px" value="MS" >Montserrat</option><option style="width:100px" value="MA" >Morocco</option><option style="width:100px" value="MZ" >Mozambique</option><option style="width:100px" value="MM" >Myanmar (Burma)</option><option style="width:100px" value="NA" >Namibia</option><option style="width:100px" value="NR" >Nauru</option><option style="width:100px" value="NP" >Nepal</option><option style="width:100px" value="NL" >Netherlands</option><option style="width:100px" value="AN" >Netherlands Antilles</option><option style="width:100px" value="NC" >New Caledonia</option><option style="width:100px" value="NZ" >New Zealand</option><option style="width:100px" value="NI" >Nicaragua</option><option style="width:100px" value="NE" >Niger</option><option style="width:100px" value="NG" >Nigeria</option><option style="width:100px" value="NU" >Niue</option><option style="width:100px" value="NF" >Norfolk Island</option><option style="width:100px" value="MP" >Northern Mariana Islands</option><option style="width:100px" value="NO" >Norway</option><option style="width:100px" value="OM" >Oman</option><option style="width:100px" value="PK" >Pakistan</option><option style="width:100px" value="PW" >Palau</option><option style="width:100px" value="PS" >Palestine</option><option style="width:100px" value="PA" >Panama</option><option style="width:100px" value="PG" >Papua New Guinea</option><option style="width:100px" value="PY" >Paraguay</option><option style="width:100px" value="PE" >Peru</option><option style="width:100px" value="PH" >Philippines</option><option style="width:100px" value="PL" >Poland</option><option style="width:100px" value="PT" >Portugal</option><option style="width:100px" value="PR" >Puerto Rico</option><option style="width:100px" value="QA" >Qatar</option><option style="width:100px" value="RO" >Romania</option><option style="width:100px" value="RU" >Russia</option><option style="width:100px" value="RW" >Rwanda</option><option style="width:100px" value="AS" >Samoa (American)</option><option style="width:100px" value="WS" >Samoa (western)</option><option style="width:100px" value="SM" >San Marino</option><option style="width:100px" value="ST" >Sao Tome & Principe</option><option style="width:100px" value="SA" >Saudi Arabia</option><option style="width:100px" value="SN" >Senegal</option><option style="width:100px" value="RS" >Serbia</option><option style="width:100px" value="CS" >Serbia and Montenegro</option><option style="width:100px" value="SC" >Seychelles</option><option style="width:100px" value="SL" >Sierra Leone</option><option style="width:100px" value="SG" >Singapore</option><option style="width:100px" value="SK" >Slovakia</option><option style="width:100px" value="SI" >Slovenia</option><option style="width:100px" value="SB" >Solomon Islands</option><option style="width:100px" value="SO" >Somalia</option><option style="width:100px" value="ZA" >South Africa</option><option style="width:100px" value="ES" >Spain</option><option style="width:100px" value="LK" >Sri Lanka</option><option style="width:100px" value="SH" >St Helena</option><option style="width:100px" value="SD" >Sudan</option><option style="width:100px" value="SR" >Suriname</option><option style="width:100px" value="SZ" >Swaziland</option><option style="width:100px" value="SE" >Sweden</option><option style="width:100px" value="CH" >Switzerland</option><option style="width:100px" value="SY" >Syria</option><option style="width:100px" value="TW" >Taiwan</option><option style="width:100px" value="TJ" >Tajikistan</option><option style="width:100px" value="TZ" >Tanzania</option><option style="width:100px" value="TH" >Thailand</option><option style="width:100px" value="TG" >Togo</option><option style="width:100px" value="TK" >Tokelau</option><option style="width:100px" value="TO" >Tonga</option><option style="width:100px" value="TT" >Trinidad & Tobago</option><option style="width:100px" value="TN" >Tunisia</option><option style="width:100px" value="TR" >Turkey</option><option style="width:100px" value="TM" >Turkmenistan</option><option style="width:100px" value="TV" >Tuvalu</option><option style="width:100px" value="UG" >Uganda</option><option style="width:100px" value="UA" >Ukraine</option><option style="width:100px" value="AE" >United Arab Emirates</option><option style="width:100px" value="GB" >United Kingdom</option><option style="width:100px" value="US"  SELECTED >United States</option><option style="width:100px" value="UY" >Uruguay</option><option style="width:100px" value="UZ" >Uzbekistan</option><option style="width:100px" value="VU" >Vanuatu</option><option style="width:100px" value="VE" >Venezuela</option><option style="width:100px" value="VN" >Vietnam</option><option style="width:100px" value="VG" >Virgin Islands (UK)</option><option style="width:100px" value="WF" >Wallis & Futuna</option><option style="width:100px" value="YE" >Yemen</option><option style="width:100px" value="ZM" >Zambia</option><option style="width:100px" value="ZW" >Zimbabwe</option>
    </select>
    </td>
      </tr> 
      <tr>
    <td>
    <input type="text" name="phonenumber" value="001 X">
      </form>
    </td>
    </tr>
      </table>
    </body>
    </html>
    Originally Posted by web_loone08
    You mean something like this:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
    <script>
    
    function CountryCodeFunction(dropdown1, dropdown2, textbox)
    {
        var from = dropdown1.selectedIndex;
        var to = dropdown2.selectedIndex;
        var SelValue1 = dropdown1.options[from].value;
        var SelValue2 = dropdown2.options[to].value;
        if (SelValue1 == "BD" && SelValue2 == "US")
        {
          textbox.value = "+88"
          document.getElementById("pcode").innerHTML = "011 880 X";
        }
        else if (SelValue1 == "US" && SelValue2 == "BD")
        {
          textbox.value = "+1";
          document.getElementById("pcode").innerHTML = "00 1 X";
        }
        return true;
    }
    
    
    </script>
    
    </head>
    
    <table>
      <tr>
    <td>From:</td>
    <td>
    <form name="form">
    <select name="from" id="from" onChange="CountryCodeFunction(this.form.from, this.form.to, this.form.phonenumber)">
    <option selected>Calling From</option>
    <option value="BD">Bangladesh</option>
    <option value="US">USA</option>
    </select>
      <input type="text" name="phonenumber" value="+88">
    </td>
     </tr>
     
      <tr>
    <td>To:</td>
    <td>
    
    <select name="to" id="to" onChange="CountryCodeFunction(this.form.from, this.form.to, this.form.phonenumber)">
    <option selected>Calling To</option>
    <option value="US">USA</option>
    <option value="BD">Bangladesh</option>
    </select>
      </form>
    </td>
      </tr>
       <tr>
    <td>
    
    
    <p id="pcode">
    
    </p>
    
    
    
    
    </td>
    
      </tr>
      </table>
    
    
    
    </body>
    </html>
  6. #4
  7. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,110
    Rep Power
    119
    No... I didn't miss your point; that was an example, for you to adapt. With that many validations to have to rotate threw; yeah... you could put countries in an array and the phone code, in another array and then compare to the values of your select fields. Then use a for or while loop to cycle through the validation and use the current "if" condition, to compare corresponding array keys, from both of your arrays. So you would have to structure your arrays; in a way... that the keys would match up, to give you the results, that you desire.

IMN logo majestic logo threadwatch logo seochat tools logo