You are viewing limited content. For full access, please sign in.

Question

Question

how can you auto fill the province/state and country in a form field

asked on June 2, 2022

how can you auto fill the province/state and country in a form field

 

0 0

Replies

replied on June 3, 2022

I have a little JS I use to autofill state and country, then I hide country because we almost always sell in just the US.

 $('.State').parent().children().val("New York");
  $(".Country").parent().children().val("USA");
   $(".Country").parent().children().css('display', 'none');

 

Because we sell in the US primarily, I also have some code that changes the label to just state or province.

/* Hide Country field in the address field */

$(document).ready (function () {

   $(".Country").parent().children().css('display', 'none');

});

/* Change label of address field input box.            "State" has been changed to "Province".*/

$(document).ready (function () {

  $(".State").siblings().text('State');

});

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.