Forum Moderators: coopster

Message Too Old, No Replies

Trouble with JSDatePick

         

SeanF

9:26 pm on Mar 1, 2020 (gmt 0)

5+ Year Member Top Contributors Of The Month



I'm going crazy trying to troubleshoot this one...

I am using jsDatePick.min.1.3.js in an included file to select dates for input forms in different web pages.

In one file it works fine, in the other it always returns a null value.

My code looks like this:


$next_action_year = date('Y');
$next_action_month = date('m');
$next_action_day = date('d');

$selected_date =
"
selectedDate:{
year:$next_action_year,
month:$next_action_month,
day:$next_action_day
},
";

echo "
<script type='text/javascript'>
window.onload = function(){
new JsDatePick({
useMode:2,
target:'inputField',
dateFormat:'%m-%d-%Y',
$selected_date
});
};
</script>
";
echo "<input type='text' size='12' name='next_action_date' id='inputField' value = '$next_action_month-$next_action_day-$next_action_year' />";


The odd thing is, if I remove "id='inputField'" from the "input" field, obviously, there is no date selection calendar but the $_POST['next_action_date'] returns a valid value.

Otherwise, the $_POST['next_action_date'] vat=riable is empty.

What am I missing?

lammert

9:46 pm on Mar 1, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is the problem browser-specific, or does it happen with all browsers? You only posted one code example. Is this for the file it works fine, or for the file which returns a NULL value. It would be nice to know the differences between the two files to spot the problem more easily.

SeanF

11:08 pm on Mar 1, 2020 (gmt 0)

5+ Year Member Top Contributors Of The Month



The previously quoted code is the code for the "included" file which both pages use. Unfortunately, including the total code for all pages would be unreasonable

The include command in both pages is
include ('includes/biz_dev_entry_form.php');


On both pages, the calendar selection works as suspected and fills in the "next_action_date" form field with a valid string in the correct format (MM-DD-YY)

Both pages which have this form included have the following lines as the FIRST lines after checking that the form has been submitted:
if (isset($_POST['submit'])) {
$nextAction = $_POST['next_action'];
echo "Next Action: $nextAction <br/>";
$nextActionDate = $_POST['next_action_date'];
echo "Next Action Date: $nextActionDate <br/>";
exit();

Both pages return a valid value for $nextAction, only one page returns a valid value for $nextActionDate

One page Returns:
Next Action: call sammy again
Next Action Date: 12-07-2018


The Other page returns:
Next Action: Call Mary to discuss details
Next Action Date:


So, the $_POST['next_action'] value is being passed correctly in both cases and I can't see anything which would cause the $_POST['next_action_date'] value to fail on one and not the other.

Neither file has any other variables mistakenly called "next_action_date"

Further, If I wrap a
if (isset($_POST['next_action_date'])){

Around the echo "Next Action Date: $nextActionDate <br/>"; statement, it is not even displayed so something is keeping the $_POST variable from being passed. (It's not even passing a null value)

This is driving me crazy

SeanF

1:15 am on Mar 2, 2020 (gmt 0)

5+ Year Member Top Contributors Of The Month



More on this... Form fields that come after the JSDatePick form pass correct $_POST variables, so it's not that the form is being truncated.

Also, By simply removing the "id='inputField'" from the input tag makes it work fine...

... so confused

coopster

7:34 pm on Mar 23, 2020 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Late thought here but you don't happen to have multiple input fields with the same identifier on the other page by chance, do you?