i use function of geonames locate countries connect. , problem have fill in phone number field @ beginning telephone code, telephone code depends of country. in solution, code works if select country, when page charged (detected geonames country), country displayed not phone code.
what solution?
example:
country = france telephone code = +33 in code : country = france telephone code = +93 (first country in list , not of france !!)
setindicatif = function(element){ var indicatif = $(element).find('option:selected').attr('indicatif') ; $('#tel_struct').val('+('+indicatif+') '); } setindicatif($('#country')); $('#countryselect').on('change', function() { setindicatif(this); });
<!-- country ------> <select id="countryselect" name="country" onchange="check()"> <?php $reponse = $bdd->query('select * pays'); echo '<option value="" indicatif="">pays</option>'; while ($donnees = $reponse->fetch(pdo::fetch_assoc)) { echo '<option value="'.$donnees["id_pays"].'" indicatif="'.$donnees["code_pays"].'">'.$donnees["pays"].'</option>'; } ?> </select> <!--telephone--> <input type="tel" name="tel_struct" id="tel_struct" placeholder="téléphone générique">
Comments
Post a Comment