Get value for joomla calendar input box to use in ajax call

by user1616338   Last Updated October 13, 2019 19:10 PM

I have a joomla calendar set up:

        <?php
        defined('_JEXEC') or die;
        JHTML::_('behavior.calendar');
        echo '<div id="calendarBoxes"  >';
        echo '<div id="datereceived1" class="datereceived1" >';
        echo JHtml::calendar(date("d/m/Y"),'dateReceived','dateReceived' , '%d-%m-%Y');
        echo "</div>";

This works fine and shows the calendar which then populates the box correctly.

I need to get the populated value so that I can use it in an ajax call to save it to a database.

I'm doing this:

stock.datereceived = jQuery( "#dateReceived" ).val();

but this returns nothing.

I looked at the code inspector and I can see the value:

<input type="text" id="dateReceived" name="dateReceived" value="" data-alt-value="13-10-2019" autocomplete="off" data-local-value="13-10-2019">

but I can't access the data. I can't use

jQuery("#dateReceived).attr("data-alt-value");
jQuery("#dateReceived).val();

And I can't find any getter or setter for the calendar.

Any help would be great. thanks



Related Questions


Updated March 13, 2019 11:10 AM

Updated September 30, 2017 16:10 PM

Updated August 24, 2016 08:04 AM

Updated February 16, 2017 14:10 PM

Updated January 30, 2018 17:10 PM