Try this:
<script>
function passVariable() {
var strStartDate = document.getElementById("from_date").value;
var strEndDate = document.getElementById("to_date").value;
var googleURL = 'https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A76546294&dimensions='+'ga%3Asource&metrics=ga%3Ausers&sort=-ga%3Ausers&start-date='+strStartDate+'&end-date='+strEndDate+'&max-results=10';
alert(googleURL);
}
</script>
Read this to understand the
Scope in JavaScript[
^].
++++++++[Round 2]+++++++++
You have typed the wrrong names, should be strStartDate not startDate, Try this:
<script>
var strStartDate;
var strEndDate;
function testVal(){
var googleURL = 'https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A76546294&dimensions='+'ga%3Asource&metrics=ga%3Ausers&sort=-ga%3Ausers&start-date='+strStartDate+'&end-date='+strEndDate+'&max-results=10';
alert(googleURL);
}
function passVariable() {
strStartDate = document.getElementById("from_date").value;
strEndDate = document.getElementById("to_date").value;
alert(strStartDate);
alert(strEndDate);
testVal();
}
</script>