My function is the call that is made by the onchange event in an html select type input.
I assign a variable that value, but it doesn't seem to get accessed by a variable of the same name outside that function, say, in $(document).ready()
<select form="submitForm" name="frequency" class="meal-type-select" onchange="getFreqVal(this)">
<option value="O">One Time</option>
<option value="D">Daily</option>
<option value="W">Weekly</option>
<option value="M">Monthly</option>
<option value="Y">Yearly</option>
<option value="R">Requested</option>
</select>
And the script is this: (There is a lot more to the script, but I've only shown the part relevant to the question, to make it less clattered)
<script>
$(document).ready(function() {
var freqVal;
$('#addPictures').click(function() {
alert(freqVal);
});
});
function getFreqVal(sel)
{
freqVal = sel.value;
alert(freqVal);
}
</script>
var freqVal;out of the document ready function.. to start of the script block..