Query Data items

Is it possible to change the scope of a variable in a range of Data items?
Here is my code

{{range .Site.Data.country}}
      <option value="{{.location}}">{{.location}}</option>

I want to be able to make .location a global variable scope.

I want to create an if statement out of the .location on a different range of data. Is this possible?

No. You have to define the global variable before the range.

{{ $globalLoc := "" }}
{{range .Site.Data.country}}
      {{ $globalLoc = .location }}
      <option value="{{.location}}">{{.location}}</option>
{{ $globalLoc }}

See Introduction to Hugo Templating | Hugo.

Thank you.

I want to be able to pick the value location from the option value in .Site.Data.country.
How do I have that?

Something like this.
if .location in .Site.Data.country is selected .ie value = to Books

Then have the disable attribute on some other form input true if not it should show up

You asked the same question a month ago, and my guidance has not changed:

It seems like you want to create an HTML form with a dependent dropdown, which is “off topic” for this forum. You might start by searching Stack Overflow.

You would want to use JavaScript for this.