Skip to main content
added 377 characters in body
Source Link
user1616338
  • 407
  • 2
  • 10

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

Update 1

I've tried a few debug type things without success:

stock.datereceived = jQuery( "#dateReceived" ).val();
console.log("stock.datereceived is "+stock.datereceived);
console.log("getElementById is "+jQuery("dateReceived").attr("data-alt-value") );

which gives stock.datereceived is stock-lists:268 getElementById is undefined in the element inspector

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

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

Update 1

I've tried a few debug type things without success:

stock.datereceived = jQuery( "#dateReceived" ).val();
console.log("stock.datereceived is "+stock.datereceived);
console.log("getElementById is "+jQuery("dateReceived").attr("data-alt-value") );

which gives stock.datereceived is stock-lists:268 getElementById is undefined in the element inspector

Source Link
user1616338
  • 407
  • 2
  • 10

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

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