Osclass Support Forums

Osclass theme support => Sigma Osclass Theme => Topic started by: chris on December 08, 2020, 11:04:27 AM

Title: [help] auto selection of a lonely country
Post by: chris on December 08, 2020, 11:04:27 AM
hi,

i have only one country on my website : France (and it will stay like this)

i want location input shown as a dropdown list

i want users can access the item-post.php file even if they are not logged in (or if they are but they have not selected a city as user)

There is a little problem in that case, because :

as there is only one country, country choice does not appear in item-post.php but the country is not pre selected so you can't select a region, and neither a city.

i would like that the country be auto selected. That way, when user want to add his listing, he should directly select a region which is under the country (France in my case, PK_C_CODE = "FR")

Thanks for your time guys !

Title: Re: [help] auto selection of a lonely country
Post by: MB Themes on December 08, 2020, 03:31:31 PM
@chris
If you add following code to your item-post.php, it could work.
Code: [Select]
<script>
$(document).ready(function() {
  $('select[name="countryId"]').val($('select[name="countryId"] option:last').val());
  $('select[name="countryId"]').change();
});
</script>

or

Code: [Select]
<script>
$(document).ready(function() {
  $('select[name="countryId"]').prop("selectedIndex", 1);
  $('select[name="countryId"]').change();
});
</script>
Title: Re: [help] auto selection of a lonely country
Post by: chris on December 09, 2020, 11:02:46 AM
thank you very much. i will buy you 2 or 3 plugins
Title: Re: [help] auto selection of a lonely country
Post by: MB Themes on December 09, 2020, 11:17:54 AM
@chris
Or 23  8)
Title: Re: [help] auto selection of a lonely country
Post by: chris on January 14, 2021, 09:19:09 AM
i've bought 3, as you can notice, but waiting for some answers on other topics to buy more  :)
Title: Re: [help] auto selection of a lonely country
Post by: MB Themes on January 14, 2021, 12:43:11 PM
@chris
Approved.