Results 1 to 4 of 4

Thread: Javascript Help

  1. #1

    Exclamation Javascript Help

    I am attempting to edit a customization done by another person for a shopping cart checkout page done in PDGCommerce

    The customization is a calendar date picker which allows the customer to choose a delivery date. When it was originally coded we asked that 2 days of the week be blocked from the calendar since we do not ship on those days.

    I have checked the code out and added what I thought would be a simple variable to block out a additional day of the week. However it does not work.


    Here is the original code:
    Code:
    // checkout_calendar.js
    
    function mySelectHandler(type,args,obj) {
    	var selected = args[0];
        var selDate = this.toDate(selected[0]);
    	var formShipMethod = document.getElementById('shipmethod');
    	var formShipWarn = document.getElementById('shipWarnContainer');
    	
    	// Set the value of the delivery date pass through field
    	var formDeliveryDate = document.getElementById('PASSDeliveryDate');
    	formDeliveryDate.value = selDate;
    	
    	// IF SAT delivery, then increase the price by $20
    	if (6 == selDate.getDay())
    	{
    		simpledialog1.render(document.body);
    		simpledialog1.show();
    	}
    	else
    	{
    		// IF not SAT delivery, then reset to defaults
    		formShipMethod.value = "0";
    		formShipWarn.style.display = "none";
    	}
    	
    };
    var mySundayRenderer = function(workingDate, cell) {
    			cell.innerHTML = "X";
    			YAHOO.util.Dom.addClass(cell, "sunday");
    			return YAHOO.widget.Calendar.STOP_RENDER;
    		}
    var myMondayRenderer = function(workingDate, cell) {
    			cell.innerHTML = "X";
    			YAHOO.util.Dom.addClass(cell, "monday");
    			return YAHOO.widget.Calendar.STOP_RENDER;
    		}	               		
    
    // Define various event handlers for Dialog
    var handleYes = function() {
    	var formShipMethod = document.getElementById('shipmethod');
    	var formShipWarn = document.getElementById('shipWarnContainer');
    	formShipMethod.value = "1";
    	formShipWarn.style.display = "block";
    	this.hide();
    };
    
    var handleNo = function() {
    	this.hide();
    };
    
    var simpledialog1;
    
    function initPopupWindow()
    {
       simpledialog1 = 
    	new YAHOO.widget.SimpleDialog("simpledialog1", 
    			 { width: "300px",
    			   fixedcenter: true,
    			   visible: false,
    			   draggable: false,
    			   close: true,
    			   text: "You will be charged an extra $20 for Saturday delivery.<br><br>Do you agree to this charge?",
    			   icon: YAHOO.widget.SimpleDialog.ICON_WARN,
    			   constraintoviewport: true,
    			   buttons: [ { text:"Yes", handler:handleYes, isDefault:true },
    						  { text:"No",  handler:handleNo } ]
    			 } );
    	simpledialog1.setHeader("Additional Shipping Required");
    As you can see Sunday and Monday have been blocked from the calendar.

    Here is the current code which I added an additional argument to:
    // checkout_calendar.js

    function mySelectHandler(type,args,obj) {
    var selected = args[0];
    var selDate = this.toDate(selected[0]);
    var formShipMethod = document.getElementById('shipmethod');
    var formShipWarn = document.getElementById('shipWarnContainer');

    // Set the value of the delivery date pass through field
    var formDeliveryDate = document.getElementById('PASSDeliveryDate');
    formDeliveryDate.value = selDate;

    // IF SAT delivery, then increase the price by $20
    if (6 == selDate.getDay())
    {
    simpledialog1.render(document.body);
    simpledialog1.show();
    }
    else
    {
    // IF not SAT delivery, then reset to defaults
    formShipMethod.value = "0";
    formShipWarn.style.display = "none";
    }

    };
    var mySundayRenderer = function(workingDate, cell) {
    cell.innerHTML = "X";
    YAHOO.util.Dom.addClass(cell, "sunday");
    return YAHOO.widget.Calendar.STOP_RENDER;
    }
    var myMondayRenderer = function(workingDate, cell) {
    cell.innerHTML = "X";
    YAHOO.util.Dom.addClass(cell, "monday");
    return YAHOO.widget.Calendar.STOP_RENDER;

    }
    var myTuesdayRenderer = function(workingDate, cell) {
    cell.innerHTML = "X";
    YAHOO.util.Dom.addClass(cell, "tuesday");
    return YAHOO.widget.Calendar.STOP_RENDER;
    }


    // Define various event handlers for Dialog
    var handleYes = function() {
    var formShipMethod = document.getElementById('shipmethod');
    var formShipWarn = document.getElementById('shipWarnContainer');
    formShipMethod.value = "1";
    formShipWarn.style.display = "block";
    this.hide();
    };

    var handleNo = function() {
    this.hide();
    };

    var simpledialog1;

    function initPopupWindow()
    {
    simpledialog1 =
    new YAHOO.widget.SimpleDialog("simpledialog1",
    { width: "300px",
    fixedcenter: true,
    visible: false,
    draggable: false,
    close: true,
    text: "You will be charged an extra $20 for Saturday delivery.<br><br>Do you agree to this charge?",
    icon: YAHOO.widget.SimpleDialog.ICON_WARN,
    constraintoviewport: true,
    buttons: [ { text:"Yes", handler:handleYes, isDefault:true },
    { text:"No", handler:handleNo } ]
    } );
    simpledialog1.setHeader("Additional Shipping Required");
    I assumed that by adding the below variable that Tuesday would also be blocked on the calendar. However it is not.
    Code:
    var myTuesdayRenderer = function(workingDate, cell) {
    			 cell.innerHTML = "X";
    			 YAHOO.util.Dom.addClass(cell, "tuesday");
    Any help would be greatly appreciated. Also,I am willing to pay a small fee to someone who could fix this for me if needed.

    TIA
    www.tcadmin.com
    The Game Hosting Control Panel

  2. #2
    Join Date
    Apr 2008
    Posts
    306
    You've made what seems to be the right. However, you are declaring the function, but never calling it.

    PHP Code:
    var myTuesdayRenderer = function(workingDatecell) {
    cell.innerHTML "X";
    YAHOO.util.Dom.addClass(cell"tuesday");
    return 
    YAHOO.widget.Calendar.STOP_RENDER;
    }

    myTuesdayRenderer(); // Add this line or just don't use a function at all. 
    Heymman - Beefy servers, tiny price !

  3. #3
    Thank you for your answer. However I am curious as to why the Sunday and Monday vars work and the Tuesday var does not.

    I do not see the other vars being called in the above code???

    I did add the line you suggested with the same result.

    I will admit I am a complete noob when it comes to code and Javascript.
    Last edited by TCA; 05-19-2011 at 03:44 PM.
    www.tcadmin.com
    The Game Hosting Control Panel

  4. #4
    Join Date
    Apr 2008
    Posts
    306
    Those functions could be called in another file as well.

    I apparently skipped a step : you obviously got to define myTuesdayRenderer's parameters.

    You'd need to find out where those functions are called to determine what cell variable is. Feel free to post a live, working demo so WHTers and I may further troubleshoot this, since I've personally never used this Yahoo widget.
    Heymman - Beefy servers, tiny price !

Similar Threads

  1. please help with javascript
    By lemondude in forum Programming Discussion
    Replies: 3
    Last Post: 07-11-2007, 11:07 PM
  2. Need Some Javascript Help
    By O.D.S. in forum Programming Discussion
    Replies: 2
    Last Post: 06-10-2006, 09:35 PM
  3. Need javascript help
    By hoachen in forum Programming Discussion
    Replies: 3
    Last Post: 12-21-2005, 11:13 AM
  4. javascript function has no properties in javascript console
    By mrblack in forum Programming Discussion
    Replies: 2
    Last Post: 05-25-2005, 02:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •