0

Good Early Morning (just barely)

I have an issue with a javascript function in <head> portion of a script apparently sending something to the browser that is preventing a redirect from working the way it was before I added this JS...

Here is the JS that I added

<link type="text/css" href="jui/css/le-frog/jquery-ui-1.8.18.custom.css" rel="stylesheet" />
		<script type="text/javascript" src="jui/js/jquery-1.7.1.min.js"></script>
		<script type="text/javascript" src="jui/js/jquery-ui-1.8.18.custom.min.js"></script>
		<script type="text/javascript">
 	$(function() {
		var dates = $( "#from, #to" ).datepicker({
			defaultDate: "+1w",
			changeMonth: true,
			numberOfMonths: 1,
			onSelect: function( selectedDate ) {
				var option = this.id == "from" ? "minDate" : "maxDate",
					instance = $( this ).data( "datepicker" ),
					date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings );
				dates.not( this ).datepicker( "option", option, date );
			}
		});
	});
	</script>

After that the </head> tag comes, and then the body and a display table, etc...

All of this was working just fine...

In the table there is a comparison of a variable like this:

if ($accept != 'Y'){ // variable set in logcheck
header('Location:../memupdate.php');// if haven't accepted TOS go there
exit;
}

Before the JS code, when $accept wasn't 'Y' then it redirected just fine...
With the JS code, it ignores the redirect and just exits...

What is it in the JS code that would be interpreted as sending something to the browser, which is the only thing I can figure would be happening?

I know it is in that section of js code because if I take that out of the <head> section, the script goes back to working just fine...

Any assistance in this matter would be greatly appreciated.

Douglas

OK, I've narrowed it down even further...
If I take out this portion of the code, then it allows the page to redirect as it should

onSelect: function( selectedDate ) {
  var option = this.id == "from" ? "minDate" : "maxDate",
    instance = $( this ).data( "datepicker" ),
    date = $.datepicker.parseDate(
      instance.settings.dateFormat ||
      $.datepicker._defaults.dateFormat,
      selectedDate, instance.settings );
  dates.not( this ).datepicker( "option", option, date );
}

So what is it in that code that would cause the problem???

Any ideas?

Edited by showman13: narrowed down the trouble area

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by showman13
0

check the script files <script type="text/javascript" src="jui/js/jquery-1.7.1.min.js"></script> <script type="text/javascript" src="jui/js/jquery-ui-1.8.18.custom.min.js"></script

one of them may include a definition var accept="y";
accept is a common variable name
to continue to use the jquery libraries, try changing your accept variable to another variable name
cant be sure
just thought

0

Assuming there are no scripting errors on your code
you should try it with a defer attribute:

<script type="text/javascript" [B]defer[/B]>
 	$(function() {
		var dates = $( "#from, #to" )....
0
onSelect: function( selectedDate ) {
  var option = this.id == "from" ? "minDate" : "maxDate",
    instance = $( this ).data( "datepicker" ),
    date = $.datepicker.parseDate(
      instance.settings.dateFormat ||
      $.datepicker._defaults.dateFormat,
      selectedDate, instance.settings );
  dates.not( this ).datepicker( "option", option, date );
}

So what is it in that code that would cause the problem???

Any ideas?

OK, I'm officially baffled...
As I stated this code that I quoted above is the culprit, and it is part of the js that came with the datepicker...

But in doing some testing, and finding that if I took out this section, it eliminated the problem that I was having, I finally Also realized that the DatePicker appears to work just fine without it...

So, not sure why it was there in the first place, unless it was for some additional functionality that I haven't found a need for...

I'm thinking that I need to spend some time studying JS, so I have a better understanding of the process... I haven't a clue.

Thanks for your responses...

Douglas

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.