Javascript not working

More
3 years 10 months ago #100244 by mayurpatelza
mayurpatelza created the topic: Javascript not working
Hi,

I have multiple surveys on my server and am experiencing an odd issue in just one survey. I have added the js source to the question text but when I preview the question group it doesn't run.

I have noticed that if I simplify the js to simply pop up an alert then it works. My customised code doesn't though. I have another survey on that server that is has an exact copy of the code except for the qid's and it works correctly.

Can someone please provide some insight as to how to debug to issue? or even better provide an explaination of why that is occuring and how to fix it?

Not sure if it helps but FYI

The issue is 2 date questions that follow each other - in date 1 i have a listener for a change and it updatess date 2 with 3 things - 1. clear the old date2 value, 2. set the max date to one year after date 1, set the min date to 1 day after date1

Source for Date 1(Working code from test survey)
<script type="text/javascript" charset="utf-8">
$(document).ready(function () {
'use strict';

$('#answer418687X40X412').datepicker("option", "onClose", function (datum){
$('#answer418687X40X413').datepicker( "setDate", "" );
$('#answer418687X40X413').datepicker( "option", "minDate", datum );
$('#answer418687X40X413').datepicker( 'option', 'maxDate', new Date(parseInt(datum.substr(6,4))+1, parseInt(datum.substr(3,2))-1, parseInt(datum.substr(0,2))-1) );
});
});
</script>Date 1


from Date of Issue(Non working code from actual survey - PLEASE NOTE THAT I TRIED TO MOVE THE DATE OF EXPIRY TO THE NEXT QUESTION GROUP AS A TEST BUT THAT DIDN'T WORK SO THAT CHANGE IS REFLECTED HERE AS WELL)
<script type="text/javascript" charset="utf-8">
$(document).ready(function () {
'use strict';

$('#answer672512X15X192').datepicker("option", "onClose", function (datum){
$('#answer672512X41X193').datepicker( "setDate", "" );
$('#answer672512X41X193').datepicker( "option", "minDate", datum );
$('#answer672512X41X193').datepicker( 'option', 'maxDate', new Date(parseInt(datum.substr(6,4))+1, parseInt(datum.substr(3,2))-1, parseInt(datum.substr(0,2))-1) );
});
});
</script>Date of Issue

Thanks

Please Log in to join the conversation.

More
3 years 8 months ago #101950 by emimarz
emimarz replied the topic: Javascript not working
i have a similar problem, the js witten inside $(document).ready(); not work
could be the same

Please Log in to join the conversation.

Did you already participate in our customer survey?

Don't miss your chance for great prices.

Please click here to participate:

Start now

Start now!

Just create your account and start using Limesurvey today.

Register now