How to preselect a value with special character on Radio List with URL variable query

64 views Asked by At

I am trying to add the autofill or pre-populate feature to a Wordpress form using URL Query Variable but I am having problem when the value from a RADIO LIST that I want to pre-select contains special characters, specifically spacebar, parenthesis, period, and forward slash. Below is my code for the radio list:

var specified = ( getQueryVariable("specified") != false ) ? 
decodeURI(getQueryVariable("specified")) : '';

if ( specified != false && $('input[name=school]').length > 0 ) {
  $('input[name=school][value=' + specified + ']')
  .prop('checked', true);
  }

For example, if I want to pre-select my radio list item "United States", simply having URL input of "www.mydomain.com/?specified=United%20States?"

All other field types in the form work fine with the UTF-8 characters.

Any help is greatly appreciated!!!

0

There are 0 answers