Welcome, Guest
Username: Password: Remember me

TOPIC: Javascript not working

Javascript not working 1 year 1 month ago #100244

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
The administrator has disabled public write access.

Javascript not working 11 months 3 weeks ago #101950

  • emimarz
  • emimarz's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 24
  • Thank you received: 5
  • Karma: 1
i have a similar problem, the js witten inside $(document).ready(); not work
could be the same
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.093 seconds
Donation Image