Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7696771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:51:27+00:00 2026-05-31T21:51:27+00:00

I have to edit my question just to make it clear. What I need

  • 0

I have to edit my question just to make it clear. What I need to do is attach the value of startdate and enddate on this jsonData.php.

If the text field is empty, the defaul values will show, but if not..startdate and endate values should be what was entered by the user.

    <script type="text/javascript">

var startdate = "2012-01-01";
var enddate = "2012-01-06";


var jsonData = $.ajax({
          url: "jsonData.php?startdate="+ startdate +"&enddate="+ enddate,
          dataType:"json",
          async: false
          }).responseText;

MY Text field code:

Start Date: <input type="text" name="startdate" id="startdate"/>
End Date: <input type="text" name="enddate" id="enddate"/>

I tried using this code, but it didnt work:

var startdate = "2012-01-01";
var enddate = "2012-01-06";

if (document.getElementById('startdate').value == ''){

startdate = "2012-01-01";
}
else{
startdate = document.getElementById('startdate').value;
}


if (document.getElementById('enddate').value == ''){
 enddate = "2012-01-06";
}

else{
enddate = document.getElementById('enddate').value;
}

Im getting that error because I have declared the variables on separate script tags. How will i Fix this.
enter image description here

UPDATE 2: Whole code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>


 <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script type="text/javascript">

    google.load('visualization', '1', {'packages':['corechart','piechart']});
          </script>




<script type="text/javascript">



  $(document).ready(function() {
    $('.date').datepicker({dateFormat: "yy-mm-dd"});

            var startDate = $('#startdate');
            var endDate = $('#enddate');


            if (startDate.val() == '') {
                startDate.val('2012-01-01');
            }

            if (endDate.val() == '') {
                endDate.val('2012-01-06');
            }

  });





        var pieJsonData = $.ajax({
          url: "overall_calls_forms_pos_pie.php",
          dataType:"json",
          async: false
          }).responseText;

    var pieData = new google.visualization.DataTable(pieJsonData);



      var pieJsonData2 = $.ajax({
          url: "overall_ban_pos_pie_date.php?startdate="+ startdate +"&enddate="+ enddate,
          dataType:"json",
          async: false
          }).responseText;

    var pieData2 = new google.visualization.DataTable(pieJsonData2);

function pieChart() {



pieChartWrapper = new google.visualization.ChartWrapper({
          'chartType': 'PieChart',
          'containerId': 'pie_div',
      'dataTable':pieData,
          'options': {
    chartArea:{left:10,top:40,height:200,width:300},
    width:360, 
    height:260,
    title: "Positive Contacts Percentage", 
    titleTextStyle:{fontSize:14},
    tooltip:{showColorCode:true},
    legend:{textStyle:{fontSize: 12},position:'left'},
    pieSliceTextStyle:{fontSize: 12}

          }
        });

       google.visualization.events.addListener(pieChartWrapper, 'ready', pieReady);

pieChartWrapper.draw();
}

 function pieReady() {

        // Change the pie chart rendering options when clicked.
        document.getElementById('optionsButton').onclick = function() {
          pieChartWrapper.setDataTable(pieData2);
          pieChartWrapper.draw();
        };
        document.getElementById('optionsButton2').onclick = function() {
           pieChartWrapper.setDataTable(pieData);
           pieChartWrapper.draw();
         };

      }



google.setOnLoadCallback(pieChart);


</script>
  </head>
  <body>



Start Date: <input type="text" name="startdate" class="date" id="startdate"/>
End Date: <input type="text" name="enddate" class="date" id="enddate"/>

            <div id="buttons">
  <button style="margin: 2em" id="optionsButton">Get My Data 2</button> 
  <button style="margin: 2em" id="optionsButton2">Get My Current Data</button>      
    </div>
    <div id="pie_div" style="float:left;"></div>     


  </body>
</html>

I USED: to correct my mistake. But the chart doesnt redraw unless the page refreshes.

  $(document).ready(function() {
    $('.date').datepicker({dateFormat: "yy-mm-dd"});


            var startDate =  document.getElementById('startdate').value;

            var endDate = document.getElementById('enddate').value;



            if (startDate == '') {
                startDate = ('2012-01-01');
            }

            if (endDate == '') {
                endDate = ('2012-01-13');
            }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:51:28+00:00Added an answer on May 31, 2026 at 9:51 pm

    If I understand this correctly, this is what you want probably.

    Start Date: <input type="text" name="startdate" id="startdate" class="date" />
    End Date: <input type="text" name="enddate" id="enddate" class="date" />
    
    <script>
        $(document).ready(function() {
            $('.date').datepicker({dateFormat: 'yy-mm-dd'});
    
                var startDate = $('#startdate');
                var endDate = $('#enddate');
    
                if (startDate.val() == '') {
                    startDate.val('2012-01-01');
                }
    
                if (endDate.val() == '') {
                    endDate.val('2012-01-06');
                }
        });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: Just wanted to make the question I have more clear. I pretty much
This seems like such a simple question. I have several Edit boxes on my
Intro: EDIT: See solution at the bottom of this question (c++) I have a
Edit: I've learned much since the posting of this question, and so I have
I don't have a specific scenario in mind, but this question just crossed my
I have a webapp written in PHP using a MySQL database backend. This question
Edit (updated question) I have a simple C program: // it is not important
Edit: original question below, but I revise it now that I have some code
Okay I edit my question, try to explain it more clearly: I have a
EDIT: I have changed the question as it was too localized and gained negative

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.