Get the value of a selected item in a script

How would you write this in a PlanetPress Connect Designer script?

I want to take this value to locate a record in the data.

If you have a select element that looks like this:

<select id="ddlViewBy">
  <option value="1">test1</option>
  <option value="2" selected="selected">test2</option>
  <option value="3">test3</option>
</select>

Running this code:

var e = document.getElementById("ddlViewBy");
var strUser = e.options[e.selectedIndex].value;

Would make strUser be 2.

If you’re using a Foundation-based template (or if you are using jQuery):

var strUser = $("#ddlViewBy").val();

With plain old HTML:

var struser = document.getElementById("ddlViewBy").value;