0

I have a list of states and addresses of our providers by state. I want the output address to display when a state is selected. I've tried scripts found here on Stackoverflow, but cannot get them to work. The code I have figured out is below. I cannot figure out how to make the selection to create an address output.

<p><strong>Our Law Firms</strong></p>
<p>LegalShield has a network of dedicated law firms in 50&nbsp;states and 4 Canadian provinces made up of seasoned lawyers with an average of 22&nbsp;years experience. Our provider law firms provide legal protection to over a million members any time they need it, even in covered emergency situations, 24/7, 365 days a year.</p>
<p><label for="stateselect">Select Your Your State </label></p>
<select id="Provider">
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District Of Columbia</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jaersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
</select>
<p>
  
  
<script>// <![CDATA[
var Provider = document.getElementById("Provider"),
          Provideraddress = document.getElementById("phoneNumber"),
          stores = {
            noSelection: "",
            Lowestoft: "12345678",
            GtYarmouth: "222 444 666",
            Norwich: "999 999 999",
            Diss: "0000000000000"
          }
          
      nearestStore.onchange = function(){
        Address.innerHTML = stores[this.value];
      }
// ]]></script>
</p>
  • 1
    Can you please provide some more information as to what error are you seeing the console? Right here, it complains nearestStore is not defined. – Uresh K Jun 05 '17 at 17:29
  • I'm not getting an error. It just doesn't display anything for the output. – Erin Stubing Jun 05 '17 at 18:33
  • Your code snippet looks somewhat incomplete. Also, looks like you used comma (,) as statement termination instead of semi-colon (;). I looked at your code and it seems on selecting a particular nearest store on your page, you wanted to see the address in the "Address" element. However, the lookup you are doing in stores array is yielding nothing because, there would not be an entry in the stores for any particular value. Also, there is no indication on how the value of the selected state is used in the above code snippet. Please provide all the relevant information to look into the issue. – Uresh K Jul 26 '17 at 20:44

0 Answers0