How can I connect the JS value to the database?

Discussion in 'JavaScript' started by JacksonH, Oct 18, 2009.

  1. #1
    Hi,

    I just installed the JQuery date picker. http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo. It works perfectly. But how can I pass the value to the database? I have a field called "requestdate" in my database. And my codes on my body for the data picker are as fellow:


    <div id="container">
    <form name="chooseDateForm" id="chooseDateForm" action="#">
    <fieldset>
    <li>
    <input name="date1" id="date1" class="date-pick" />
    </li>
    </fieldset>
    </form>

    </div>
    <!-- page specific scripts -->
    <script type="text/javascript" charset="utf-8">
    $(function()
    { $('.date-pick').datePicker();
    });
    </script>
     
    JacksonH, Oct 18, 2009 IP
  2. DollaradeConner

    DollaradeConner Active Member Affiliate Manager

    Messages:
    200
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Are you using it to populate an input box, that will then be submitted some how?

    Javascript is a client side language, while PHP and MySQL are server side, so I don't believe you can communicate with your database via pure Javascript.

    If you are submitting a form after a date is selected, then the next page should be in PHP or some other language which will allow you to place it in a database. If everything is on page, what you could do is create a simple PHP script that uses the GET method to retrieve data, and use ajax to call this script like:

    http://www.your_domain.com/?requestdate=[the_date]

    Provide a bit more info on it.
     
    DollaradeConner, Oct 23, 2009 IP